#include #include #include int main(int argc, char** argv) { FILE* f; if (argc < 2) { fprintf(stderr, "usage: %s [file]", argv[0]); return 1; } f = fopen(argv[1], "w"); if (!f) { perror(argv[1]); return 1; } char buffer[4096]; while (1) { char* rc = fgets(buffer, sizeof(buffer), stdin); if (rc == 0) break; fputs(buffer, f); } fclose(f); return 0; }