Use gdb on the core it dumps. My guess is that fopen is returning NULL for some reason (no write access to the file? Directory doesn't exist?)
Also, make sure that str1 and str2 are NULL-terminated.
I'd recommend changing your code to something like this:
-----
if((fp = fopen("somefile", "w")) == NULL)
{
fprintf(stderr, "Couldn't open file for writing: %s\n", strerror());
return;
}
fprintf(fp, "%s%s", str1, str2);
-----
You'll have to #include <errno.h> for strerror(). It would at least tell you the reason it can't open the file (if that really is the problem) then.
Last edited by itsme86; 01-08-2004 at 08:41 PM.
|