Programming Reference/Librarys
Question & Answer
Q&A is closed
/* * fputc example code * http://code-reference.com/c/stdio.h/fputc */ #include <stdio.h> /* including standard library */ //#include <windows.h> /* uncomment this for Windows */ int main( void ) { FILE *stream, *stream_target; char c; if((stream=fopen("test.txt","rb"))==NULL) { printf("Cannot open file.\n"); return 1; } if((stream_target=fopen("testcopy.txt","wb"))==NULL) { printf("Can't write to target\n"); return 1; } printf("copy file\n"); while((c = fgetc(stream) ) != EOF) { fputc(c, stream_target); } fclose(stream); fclose(stream_target); return 0; }
test.txt - content
Test 1234
testcopy.txt content after copy
Test 1234
output: ./fputc copy file