fork download
  1. void str_cat(char** dest, const char* source)
  2. {
  3. size_t destLength = strlen(source);
  4. if (dest != NULL)
  5. {
  6. destLength += strlen(*dest);
  7. }
  8. char* temp = malloc(destLength + 1); //allocates enough memory for the old string + new string
  9. if (temp != NULL)
  10. {
  11. strcat(temp,source);
  12. }
  13. free(*dest);
  14. *dest = temp;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void str_cat(char**, const char*)’:
prog.cpp:3: error: ‘size_t’ was not declared in this scope
prog.cpp:3: error: expected `;' before ‘destLength’
prog.cpp:4: error: ‘NULL’ was not declared in this scope
prog.cpp:6: error: ‘destLength’ was not declared in this scope
prog.cpp:6: error: ‘strlen’ was not declared in this scope
prog.cpp:8: error: ‘destLength’ was not declared in this scope
prog.cpp:8: error: ‘malloc’ was not declared in this scope
prog.cpp:9: error: ‘NULL’ was not declared in this scope
prog.cpp:11: error: ‘strcat’ was not declared in this scope
prog.cpp:13: error: ‘free’ was not declared in this scope
stdout
Standard output is empty