How to write text to text file in C

1 Answer

0 votes
#include <stdio.h>
 
int main(void)
{
    FILE *fp;

    fp = fopen("d:\\test.txt","w");
    if (!fp) return 1;

    fprintf(fp, "%s\n", "C Programming");
    fprintf(fp, "%s\n", "Is The Best");

    fclose(fp);
 
    return 0;
}

/*
run: (the content of d:\\test.txt)
 
C Programming
Is The Best

*/


answered Oct 15, 2014 by avibootz

Related questions

1 answer 312 views
1 answer 299 views
1 answer 374 views
1 answer 321 views
321 views asked Aug 19, 2017 by avibootz
1 answer 256 views
256 views asked Jun 3, 2017 by avibootz
2 answers 362 views
1 answer 284 views
284 views asked Jul 15, 2015 by avibootz
...