Crashing on strcpy, not sure why?
char *temp;
strcpy(longest, temp);
strcpy
is strcpy(dst, src)
not strcpy(src, dst)
. The source is the parameter on the right, not the parameter on the left.
Moreover char *temp
is not initialized when you pass its value to strcpy
. You need to allocate memory for temp
to hold the string you copy, for example using malloc