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

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable