fork download
  1. #include <cstdlib>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. char a[100] = {'\0'};
  8. a[0] = '2';
  9. a[1] = '4';
  10. printf("%s\n" , a);
  11. a = (char*)malloc(sizeof(char)*400);
  12. *a = '4';
  13. *(a + 1) = '2';
  14. a[2] = 0;
  15. printf("%s\n" , a);
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:11:36: error: incompatible types in assignment of ‘char*’ to ‘char [100]’
  a = (char*)malloc(sizeof(char)*400);
                                    ^
stdout
Standard output is empty