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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -