Convert char array into CString
-
I have a char array like the prevois one, ( char data[64] = "101...........) but now i need to convert all of that char array into a normal mfc CString, without the char ender ofcourse. How is this easily done? ive played with strcpy, but couldnt get it to work, thanks!!!!
/Johannes
-
I have a char array like the prevois one, ( char data[64] = "101...........) but now i need to convert all of that char array into a normal mfc CString, without the char ender ofcourse. How is this easily done? ive played with strcpy, but couldnt get it to work, thanks!!!!
/Johannes
Johpoke wrote:
without the char ender ofcourse
If it's a non-Unicode build you can use CString str = data; For a unicode build you can use TCHAR data[64] = "101..........."; CString str = data; For a unicode build where the string must stay a char type you can use char data[64] = "101..........."; CStringA str = data; For a unicode build where the data must stay a char type but the CString is UNICODE you can use char data[64] = "101..........."; CString str = CA2T(data);
-
I have a char array like the prevois one, ( char data[64] = "101...........) but now i need to convert all of that char array into a normal mfc CString, without the char ender ofcourse. How is this easily done? ive played with strcpy, but couldnt get it to work, thanks!!!!
/Johannes
-
Thanks, its fixed, and yet another problem, with my char array, i now need to set it, but it doesnt seem to work, ie. char data[64]; data = "011111...."; [im feeding it the right amount of char any ideas? thanks
/Johannes
Johpoke wrote:
im feeding it the right amount of char
Are you saying there's 64 characters in your initialization string? If so then that's bad :) You need to have room for the NULL terminator. If you need 64 chars then define your data variable to a length of 65.
-
Johpoke wrote:
im feeding it the right amount of char
Are you saying there's 64 characters in your initialization string? If so then that's bad :) You need to have room for the NULL terminator. If you need 64 chars then define your data variable to a length of 65.
-
yea i know about the end part the /0 or if its a \0 but i use 63 of them, 64 with that, but i just need to be able to set all of it like data = "10100010..... its probably something simple im forgetting as usual-.. thanks
/Johannes
Johpoke wrote:
its probably something simple im forgetting as usual-..
Instead of char data[64]; data = "011111...."; try char data[64] = "011111...."; or char data[64]; strcpy(data, "011111....");
-
Thanks, its fixed, and yet another problem, with my char array, i now need to set it, but it doesnt seem to work, ie. char data[64]; data = "011111...."; [im feeding it the right amount of char any ideas? thanks
/Johannes
Johpoke wrote:
char data[64]; data = "011111....";
You might like to modify it to ,
char data[64] = {0};
data = "011111....";Prasad Notifier using ATL | Operator new[],delete[][^]