I have simple function to read txt file and I call it in the app_main(), but the returned value from fopen() is NULL.
File devices.txt is placed in main directory of project.
Code: Select all
void read(){
FILE *ptr_file;
char buf[1000];
ptr_file = fopen("devices.txt","r");
if (!ptr_file)
printf("%s","error");
else{
while (fgets(buf,1000, ptr_file)!=NULL)
printf("%s",buf);
fclose(ptr_file);
}
}