Hi all,
Can someone explain why the following error happens:
#define bla "\xA"
char a [2] = {0};
memcpy (a,bla,1); // a[0] = 0x0a <- Correct
//a[1] = bla; // '=' : cannot convert from 'const char [2]' to 'char'
Thanks,
RM
Hi all,
Can someone explain why the following error happens:
#define bla "\xA"
char a [2] = {0};
memcpy (a,bla,1); // a[0] = 0x0a <- Correct
//a[1] = bla; // '=' : cannot convert from 'const char [2]' to 'char'
Thanks,
RM
The types are different: a[1] is a char and "\xA" is an array of char.
In C++ and C anything enclosed in double quotes (including nothing) is an array of char.
Try:
#define bla '\xA'
Although that will stop the memcpy
working.