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?.
Printable View
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?.
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]);
May I suggest this?
Code:unsigned char uc[10] = "abcdefghj";
char c[10];
memcpy(c, uc, sizeof(uc));
There are no problems with signed vs unsigned chars, unless you use signed ones as array indexes... :rolleyes:Quote:
Originally Posted by 9e9+