How to write variables directly to a file with fprintf in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>
 
// int fprintf(FILE *stream, const char *format, ...) 
 
int main(void)
{
    FILE * fp;

    fp = fopen ("e://data.txt", "w");
    fprintf(fp, "%s %s %s %s %d", "We", "love", "to", "code", 2015);
   
    fclose(fp);
   
    return 0;
}
 
// file content: We love to code 2015 
 
/*
run:
   


*/

 



answered Dec 18, 2015 by avibootz

Related questions

...