cant write text file in c -


im trying learn c, i'm using tutorialspoint, , function give me doesn't on computer, function is:

#include <stdio.h>  int main (){     file *fp;      fp = fopen("/tmp/test.txt", "w+");     fprintf(fp, "this testing fprintf...\n");     fputs("this testing fputs...\n", fp);     fclose(fp); } 

am missing something?

it introduce error checking file streams

do

fp = fopen("test.txt", "w+");  /*   * try creating file in same folder start  */  if(fp!=null) { fprintf(fp, "this testing fprintf...\n"); fputs("this testing fputs...\n", fp); } else {       /* there multiple reasons can't open file :       *  don't have permission open       * parent directory doesn't exist , on.       */  printf("can't open file write\n"); } fclose(fp); 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -