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 214 views
1 answer 202 views
1 answer 273 views
1 answer 223 views
223 views asked Aug 19, 2017 by avibootz
1 answer 166 views
166 views asked Jun 3, 2017 by avibootz
2 answers 254 views
1 answer 180 views
180 views asked Jul 15, 2015 by avibootz
...