This same function works in one program and crashes in another at the line : strcpy(buf, str);
Is this an undefined behavior?
Code:int function(char * buf) { char * szLocalIP = functionreturningchar*(); char str[260]; strcpy(str, szLocalIP); char * pch = strrchr(str, '.'); str[pch-str+1] = '\0'; strcat(str, "0"); strcpy(buf, str); // crash }