Segmentation fault
hai everybody,
I worte a program and it does prints the output and after that it showed me segmentation fault error. could anybody help me out.
program is as follows:
#include <stdio.h>
int main()
{
int i,j;
FILE *f;
char *s1,*s2;
f=fopen("junk","w");
scanf("%s",s1);
if (!f)
return 1;
fwrite(&s1,sizeof(s1),1,f);
fclose(f);
f=fopen("junk","r");
if (!f)
return 1;
fread(&s2,sizeof(s1),1,f);
printf("%s\n",s2);
fclose(f);
printf("\n");
return 0;
}
|