//chararray.cpp -- testing out how to feed characters into character array.
//Michael R. Benecke
#include <iostream>
int main( )
{
using namespace std;
char name[ 20 ] = { "Michael" } ; //Works fine
cout << name;
char name1[ 20 ] ;
name1 = { 'M' ,'i' ,'c' ,'h' ,'a' ,'e' ,'l' } ; //Should work
cout << name1;
return 0 ;
}
Ly9jaGFyYXJyYXkuY3BwIC0tIHRlc3Rpbmcgb3V0IGhvdyB0byBmZWVkIGNoYXJhY3RlcnMgaW50byBjaGFyYWN0ZXIgYXJyYXkuCi8vTWljaGFlbCBSLiBCZW5lY2tlCiNpbmNsdWRlIDxpb3N0cmVhbT4KaW50IG1haW4oKQp7CiAgICB1c2luZyBuYW1lc3BhY2Ugc3RkOwoKICAgIGNoYXIgbmFtZVsyMF0gPSB7Ik1pY2hhZWwifTsgLy9Xb3JrcyBmaW5lCiAgICBjb3V0IDw8IG5hbWU7CgogICAgY2hhciBuYW1lMVsyMF07CiAgICBuYW1lMSA9IHsnTScsJ2knLCdjJywnaCcsJ2EnLCdlJywnbCd9OyAvL1Nob3VsZCB3b3JrIAogICAgY291dCA8PCBuYW1lMTsKCiAgICByZXR1cm4gMDsKfQo=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:11: error: assigning to an array from an initializer list
name1 = {'M','i','c','h','a','e','l'}; //Should work
^
stdout