Write to a file in C -


in c programming have learned file io , have run sample code is:

#include <stdio.h>  main()  {   file *fp;   fp = fopen("e:\\tmp\bae.txt", "w+");  fprintf(fp, "this testing fprintf...\n");  fputs("this testing fputs...\n", fp);  fclose(fp);   return 0; } 

here code works fine , fputs() returns -1 means code works fine. have created directory tmp on e: drive, code doesn't create file bae.txt..'

can tell me why happening?

instead of

 fp = fopen("e:\\tmp\bae.txt", "w+"); 

use

 fp = fopen("e:\\tmp\\bae.txt", "w+");   

as \ has specific meaning in string.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -