Displaying ./code/cs256su21code/jun30/writeString.c/* using fprintf to write to a file */ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ char buffer[1024]; FILE *fp = fopen("myText.txt", "w"); while(fgets(buffer, 1024, stdin) != NULL ) { fprintf(fp, "%s", buffer); } //fprintf is similar to printf execpt we're now telling it to // put the output inside a file. fclose(fp); return 0; } |