|
Can you help me to solve this problem?
aloha
|
|
|
|
|
_tcscpy and lstrcpy, both implement the same function, which one should I use if I want to copy a string in my project?
|
|
|
|
|
_UNICODE is not defined for this.
LPTSTR lstrcpy( LPTSTR lpString1,
LPTSTR lpString2
);
TCHAR is used to represent unicode strings.
So when you are working with unicode you should prefer TCHAR to LPTSTR
_TCHAR * _tcscpy(_TCHAR * to, const _TCHAR * from)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: _UNICODE is not defined for this.
LPTSTR lstrcpy( LPTSTR lpString1,
LPTSTR lpString2
);
could you see LPTSTR lstrcpy( LPTSTR lpString1, ).. T in middle
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
_tcscpy is a CRT function while lstrcpy is a windows native function. It probably does not make a difference which you use, but _tcscpy is probably better for portability reasons.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
cgsp_wei wrote: _tcscpy
use C runtime Libarary
cgsp_wei wrote: lstrcpy
use Kernel32.dll..
IMHO, it better to use Window Based api!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
cgsp_wei wrote: _tcscpy and lstrcpy, both implement the same function, which one should I use if I want to copy a string in my project?
The lstrcpy function has an undefined behavior if source and destination buffers overlap.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
So does _tcscpy.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: So does _tcscpy.
No idea,not used yet.
LPTSTR lstrcpy(LPTSTR lpString1,LPTSTR lpString2);
Using lstrcpy function incorrectly can compromise the security of your application. The first argument, lpString1, must be large enough to hold lpString2 and the closing '\0', otherwise a buffer overrun may occur. Buffer overruns may lead to a denial of service attack against the application if an access violation occurs. In the worst case, a buffer overrun may allow an attacker to inject executable code into your process, especially if lpString1 is a stack-based buffer.
Mostly application getting crashed or Access violations during such behaviour's.
ref. MSDN 2003
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Your username is broken, please fix the closing </font> tag.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: Your username is broken, please fix the closing tag.
Thank's, I have tried same earliar but name has limit of 50 characters due to which 't>' is missing.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_Laxman wrote: Thank's, I have tried same earliar but name has limit of 50 characters due to which 't>' is missing.
what about <font face="Monotype Corsiva" >A_Laxman</font>!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Have you checked size of that ??? if size not set of the font then text not display's properly.
Any way thanks for your suggestion.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
|
You will have to store the index of the selected item somewhere . Say in a file or a registry, or in a variable in your code if the application keeps on running.
The next time you open your dialog set the item to which the index points to.
Correction::|Here I assumed that you are having a fixed number of items....
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 4:44 Saturday 17th June, 2006
|
|
|
|
|
can u give code. i am unable to code that please it is urgent.
thank u,
sree.
|
|
|
|
|
sree_as wrote: i am unable to code
Are you software developer ???
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
How are you proceeding with this.
Did you try and write that index in some file/registry, Where's your logic . Where do you want to store the index for selected item.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i try to write the index in the file after thtai wnat to open it on initdialog.
CFile time;
char Pbuf[2];
time.Write(pbuf,2);
|
|
|
|
|
you create a file for a value (number or string)
but its not good idea use file instead file you can write in registry (my suggestion)
whitesky
|
|
|
|
|
iam totally confused shall u provide code for writing registry.
please thank u,
sree.
|
|
|
|
|
sree_as wrote: am totally confused shall u provide code for writing registry.
please thank u,
try Most Easiest Registry Class CRegKey!... you have to look MSDN for Same!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
where are you opening the file for writing?
CFile file;
file.Open("c:\\abc.txt",CFile::modeCreate | CFile::modeReadWrite );
CString str;
str.Format ("%d",m_combobox.GetCurSel());
file.Write(str,strlen(str));
file.Close();
// This code is not optimized
// Now read the value similarly and use m_combobox.SetCurSel() to set the text in the combo box related to the index
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 5:02 Saturday 17th June, 2006
|
|
|
|
|
i trie dto reead that file
time.Read(str,10);
it is showing error cannot convert Cstring to void
thank u,
sree.
|
|
|
|
|
sree_as wrote: i try to write the index in the file after thtai wnat to open it on initdialog.
CFile time;
char Pbuf[2];
time.Write(pbuf,2);
you can use INI file for storing these type of configuration! http://www.codeproject.com/cpp/CIni.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|