#include #include #include #include int main(int argc, char *argv[]){ if(argc < 2){ fprintf(stderr, "Usage %s filename\n", argv[0]); return 1; } //Open file to write //Try CREAT and TRUNC vs APPEND options //int fd = open(argv[1],O_WRONLY|O_CREAT|O_APPEND,0666); FILE *f = fopen(argv[1],"w"); //if (fd < 0) { // fprintf(stderr,"Could not open file %s: ",argv[1]); // perror(""); // return 1; //} //char potato[] = "potato"; //write to file //write(fd, potato, 6); char c = 'p'; fputs(c, f); fclose(f); //close(fd); return 0; }