Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
std::string
char * m_manuf = "abacus";
You cant' copy an array like that, instead of you can do,
CHAR m_manuf[256]; strcpy(m_manuf,"abacus" );
Or
char abc[256] ="abacus"; strcpy(m_manuf,abc );
Note : The better way to handle char arrays are using std::string,
Add a comment
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];
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
std::string?char * m_manuf = "abacus";probably.