Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Name and location of a file to be open or created.
- char * filename = "c:\\temp\\logfile.txt";
- /*** access mode ***
- * r or r+ = open for reading
- * w or w+ = open for writing
- * a or a+ = open for appending
- * t = text mode
- * b = binary mode
- * where the "+" sign indicates that the file must already exist *******************/
- // Open the file with append mode
- char * access_mode = "a+";
- //File pointer
- long file_stream;
- if ((file_stream = fopen(filename, access_mode)) == NULL) {
- lr_error_message ("Cannot open or create %s", filename);
- return -1;
- }
- //Write message to output file
- fprintf(file_stream, "This is the message to output file");
- //Close the file stream
- fclose(file_stream);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement