How to check if a file exists in a folder C -


I'm starting a thing and I'm a bit confused about how to do it. I'm trying with the readdir and strcmp functions but it throws me lots of errors.

  #include & lt; Stdio.h & gt; # Include & lt; Sys / types.h & gt; #include & lt; String.h & gt; # Include & lt; Dirent.h & gt; Int main (int argc, char * argv []) {DIR * dirp; Struct dirent * direntp; Dirp = opendir (argv [1]); If (dirp == NULL) {printf ("File can not be opened \ n"); Return -1; } Int i = 0; = (= () () (Print ("file is in% d directory% s mysql buddy!", Argv [2], dip);} I ++;} Monkey (DIR); return 0;} < / Code> 

  read about access (access ("myfile.txt", F_OK) )) {// file exists}  

Comments