|
-
June 24th, 2005, 02:55 PM
#1
_tcslen header file
i dont know but when i try to use _tcslen i get an error saying undefined function.
which header file i should include for _tcslen iam making a win32 app.
Regards.
"I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
FORZA MILAN!!!
-
June 24th, 2005, 02:58 PM
#2
Re: _tcslen header file
#include <string.h>
Cheers
-
June 25th, 2005, 10:46 AM
#3
Re: _tcslen header file
In fact _tcslen is a macro defined in TCHAR.H.
It expands to wcslen or strlen if _UNICODE preprocessor constant is defined or not.
wcslen and strlen functions are indeed declared in STRING.H.
Last edited by ovidiucucu; June 25th, 2005 at 10:54 AM.
-
June 26th, 2005, 01:35 AM
#4
Re: _tcslen header file
Hi!
Very sorry for the late reply as i was not able to connect.
Thanks ovidiucucu .
I dont know but i ve been running into strange problems. When ever i try using sprintf the app crashes, here is what i ve been doing:
Code:
LPTSTR pszMessage = NULL;
sprintf (pszMessage, "Hi!");
The app also crahes when i use strcat, why is all this happening?
Regards.
"I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
FORZA MILAN!!!
-
June 26th, 2005, 02:05 AM
#5
Re: _tcslen header file
 Originally Posted by logan
dont know but i ve been running into strange problems. When ever i try using sprintf the app crashes, here is what i ve been doing:
Code:
LPTSTR pszMessage = NULL;
sprintf (pszMessage, "Hi!");
of course it will crash :-) LPTSTR is unallocated pointer and you are trying to ::sprintf to him!
you have 2 options
1)
decalre TCHAR pszMessage[128]; // you will chose the size you want.
2)
LPTSTR pszMessage = new TCHAR[size you want];
after that you can do whatever you want.
if i helped dont forget to rate :-)
Cheers
-
June 27th, 2005, 07:24 AM
#6
Re: _tcslen header file
Also, if your going to use _tcslen() and TCHAR in order to be Unicode-safe, you'll probably want to use _stprintf() instead of sprintf() and _tcscat() instead of strcat().
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|