Check If A File Exists C Code Example


Example 1: c check if file exists

if( access( fname, F_OK ) == 0 ) {     // file exists } else {     // file doesn't exist }

Example 2: c check if file was created

int canCreateFile(char* path) { 	FILE* file = fopen(path, "w");   	if(file)     {   		fclose(file);       	return 1;     }   	return 0; }

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?