9e9+
February 14th, 2005, 09:25 PM
Got 10 elements of unsigned char array , uc[0],,uc[9];
like to copy it to 10 elements of char array, c[0] .. c[9].
how?.
like to copy it to 10 elements of char array, c[0] .. c[9].
how?.
|
Click to See Complete Forum and Search --> : uchar / char thing 9e9+ February 14th, 2005, 09:25 PM Got 10 elements of unsigned char array , uc[0],,uc[9]; like to copy it to 10 elements of char array, c[0] .. c[9]. how?. Kheun February 14th, 2005, 10:02 PM You can either write a loop for copying or using std::copy(). #include <algorithm> using namespace std; ... unsigned char uc[10] = "abcdefghj"; char c[10]; copy(&uc[0], &uc[0] + 10, &c[0]); cilu February 15th, 2005, 10:25 AM May I suggest this? unsigned char uc[10] = "abcdefghj"; char c[10]; memcpy(c, uc, sizeof(uc)); RoboTact February 15th, 2005, 11:00 AM Got 10 elements of unsigned char array , uc[0],,uc[9]; like to copy it to 10 elements of char array, c[0] .. c[9]. how?.There are no problems with signed vs unsigned chars, unless you use signed ones as array indexes... :rolleyes: codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |