this is my code :
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *fp;
int i,n;
char task[ 30] ;
char filename[ 30]="c:\\out.c";
fp =fopen(filename,"w");
if(fp != NULL){
printf("Enter number of tasks for today!\n");
scanf("%d", &n);
for(i=0;i<n;++i){
printf( "Enter tasks for today!\n");
scanf("%s",task);
fprintf(fp,"%s\n",task);
}
fclose(fp);
printf("\nDone!");
}else{
printf("couldn't open the file!");
exit(1);
}
return 0;
}
the only problem that I met is there is no file created
although I get the Done! message after entering the data