Hi, I'm trying to understand why I can't overwrite with strcpy on this piece of code:
I know how to work around this without using strcpy, but I need to use strcpy. I've tried allocating memory to str2 via malloc but it's the same issue. Any idea what this code is doing wrong?Code:int main (int argc, char *argv[]) { char *str2; char *str = malloc(sizeof(char)*10000); str2 = " Long text 1"; strcpy(str2, "Long text 2"); sprintf(str,"%s\n",str2); write(1,str,strlen(str)); exit(0); }