|
-
February 14th, 2005, 10:25 PM
#1
uchar / char thing
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?.
-
February 14th, 2005, 11:02 PM
#2
Re: uchar / char thing
You can either write a loop for copying or using std::copy().
Code:
#include <algorithm>
using namespace std;
...
unsigned char uc[10] = "abcdefghj";
char c[10];
copy(&uc[0], &uc[0] + 10, &c[0]);
-
February 15th, 2005, 11:25 AM
#3
Re: uchar / char thing
May I suggest this?
Code:
unsigned char uc[10] = "abcdefghj";
char c[10];
memcpy(c, uc, sizeof(uc));
-
February 15th, 2005, 12:00 PM
#4
Re: uchar / char thing
 Originally Posted by 9e9+
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...
"Programs must be written for people to read, and only incidentally for machines to execute."
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
|