BigETI

Log file tutorial

Apr 13th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.71 KB | None | 0 0
  1. //Simple log save
  2.  
  3. #define TEST_FILE   "testfile.txt" // Our definiton for a file
  4. new File:myfile; // Our file variable
  5. if(fexist(TEST_FILE)) myfile = fopen(TEST_FILE, io_append); // Does add the text after the original saved text inside the file (If the file exists of course)
  6. else myfile = fopen(TEST_FILE, io_write); // Otherwise we just create the file and add the new text in.
  7. if(myfile) // If the file does NOT return File:0, so the file has been created/opened properly.
  8. {
  9.     fwrite(myfile, "This is a text\r\n"); // We write now something inside the file
  10.     fclose(myfile); // Closes our file
  11. }
  12. else printf("Couldn't open file '%s'.", TEST_FILE); // There are some reasons why a file cannot be created/opened.
Advertisement
Add Comment
Please, Sign In to add comment