when I try to run this it throws a runtime error.
but when i commented line A it runs.can't understand what is going wrong there.can you please help me?
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void savefile(char *p);
int main(){
savefile("c proramming");
}
void savefile(char *p){
FILE*fp;
fp=fopen("result.txt","w");
if(fp==NULL){
printf("error");
exit(0);
}
strcat(p,"\n");//line A
fputs(p,fp);
fclose(fp);
}
Comment