Basic question, but are you sure your DATA folder is named InputFiles? Your post indicates that you're stopping in getDir(). With errno=2, strerror(errno) gives "No such file or directory." Using your code, unchanged except for commenting out references to OpenOutputFile(), ReadArray() and CalcAverage(), I get past getDir() as long as I enter the correct name of the DATA folder. There may be funny things going on with slashes and backslashes, so experiment.

Other errors:
When I swap the call to close() with the line above it, thus moving close() inside the if statement, then the first call to open() succeeds. The second call to open(), inside OpenInputFile(), fails, probably because the file is already open.


I'd recommend starting over; write a few lines of code and then test them by compiling and running. Use a lot of output statements so you know the program is producing the values that you expect it to. Testing a few lines at a time is much easier than a whole program at once.

Caveat: I'm using Windows, but I wouldn't think that makes a difference.