The following code opens up a list of filenames but won't open those files. Running the code shows the filename to be correct and produces an errno of 0. Permissions should allow the file to be open.
Douglass-MBP:country_data douglasbrenner$ ls -l ECHW.TXT
-rw-rw-rw-@ 1 douglasbrenner staff 17348 Aug 14 07:52 ECHW.TXT
The file can be opened elsewhere.
The list and first file are attached.
Douglass-MBP:country_data douglasbrenner$ ls -l ECHW.TXT
-rw-rw-rw-@ 1 douglasbrenner staff 17348 Aug 14 07:52 ECHW.TXT
The file can be opened elsewhere.
The list and first file are attached.
Code:
#define list_of_etfs "/Users/douglasbrenner/ANDY/ct/country_data/etfs.txt"
#define data_dir "/Users/douglasbrenner/ANDY/ct/country_data/"
externint errno;
int main(int argc, constchar * argv[])
{
FILE *etfs, *ETF;
char etf[15], filename[150];
structetf_data data;
int i,num_of_points;
int errnum;
char line[200];
//open list
if ( (etfs = fopen(list_of_etfs, "r")) == NULL)
printf("list not open\n");
// read etfs
while ((fgets(etf,sizeof(etf), etfs)) != NULL )
{
printf("%s\n",etf);
strcpy(filename,data_dir);
strcat(filename,etf);
if ((ETF = fopen(filename,"r")) == NULL)
{
printf("%s file not opened, errnum %d\n ", filename, errnum);
fprintf(stderr, "%s\n ", strerror(errnum));
exit(0);
}
else
printf("file opened\n");
fclose(ETF);
}
fclose(etfs);
/[code]