fork(1) download
  1. //chararray.cpp -- testing out how to feed characters into character array.
  2. //Michael R. Benecke
  3. #include <iostream>
  4. int main()
  5. {
  6. using namespace std;
  7.  
  8. char name[20] = {"Michael"}; //Works fine
  9. cout << name;
  10.  
  11. char name1[20];
  12. name1 = {'M','i','c','h','a','e','l'}; //Should work
  13. cout << name1;
  14.  
  15. return 0;
  16. }
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
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
Standard output is empty