Why this code won't work, on online compiler return segment fault, on my linux VPS memory leak...
#include <ctype.h>
#include <stdio.h>
#include <string.h>
char *a_foo(char *str) {
unsigned char *p = (unsigned char *)str;
while (*p) {
*p = 'a';
p++;
}
return str;
}
int main() {
char * test = "TestTest";
a_foo(test);
printf("result: %s\n", test);
}
Online Compiler: LINK