Reputation: 47
I have an array:
CHAR m_manuf[256];
I am trying to copy a value to this array as:
m_manuf = "abacus"; //This shows error
I also tried this variation:
char abc[256] ="abacus";
m_manuf = abc; //Shows error as left value must be l-value
Upvotes: 0
Views: 147
Reputation: 1225
A constant char array is good enough for you so you go with,
string tmp = "abacus";
char *new = tmp.c_str();
Or you need to modify new char array and constant is not ok, then just go with this
char *new = &tmp[0];
Upvotes: 0
Reputation: 912
You cant' copy an array like that, instead of you can do,
CHAR m_manuf[256];
strcpy(m_manuf,"abacus" );
Or
char * m_manuf = "abacus";
Or
char abc[256] ="abacus";
strcpy(m_manuf,abc );
Note : The better way to handle char arrays are using std::string,
Upvotes: 2