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
Post a Comment