fork download
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char * name;
  8. char * myname = "jeong";
  9. name = new char()[strlen(myname) + 1];
  10. strcpy(name,myname);
  11. cout << name << endl;
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:8:18: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  char * myname = "jeong";
                  ^~~~~~~
prog.cpp:9:19: error: expected ‘;’ before ‘[’ token
  name = new char()[strlen(myname) + 1];
                   ^
                   ;
stdout
Standard output is empty