Homepage › Forums › Articles › Programming › C, C++, and C# › C Code Examples: File IO Tests
This topic was published by DevynCJohnson and viewed 1804 times since "". The last page revision was "".
Viewing 1 post (of 1 total)
- AuthorPosts
Test if File Exists
int fileexists(const char *filename) { // Test if the file exists FILE *fileptr; fileptr = fopen(filename, "r"); if (fileptr != NULL) { fclose(fileptr); return 1; } return 0; }
Test if File is Writable
int filewritable(const char *filename) { // Test if the file is writable FILE *fileptr; fileptr = fopen(filename, "wb"); if (fileptr != NULL) { fclose(fileptr); return 1; } return 0; }
Further Reading
- Programming and Development - https://dcjtech.info/topic/programming-and-development/
- C Programming Article Forum - https://dcjtech.info/forum/articles/programming/c-c-and-c/
- C Code Examples: Array Rotations - https://dcjtech.info/topic/c-code-examples-array-rotations/
- C Code Examples: Return System Endianness - https://dcjtech.info/topic/c-code-examples-return-system-endianness/
- C Code Examples: Stack and Queue Datatype - https://dcjtech.info/topic/c-code-examples-stack-and-queue-datatype/
- AuthorPosts
Viewing 1 post (of 1 total)