Wednesday, March 9, 2011

new function

I had a heck of a time getting my basic .plx file header reader functional. I toss in a liberal amount of error messages for if things go wrong and I kept getting NULL returned for my file pointer, meaning the file wasn't found to be read.

I decided that I didn't understand WHERE to put the file to be read, so I had to figure out where the program was looking for the file. I had assumed it was in the same directory as the executable itself, but I turned out to be wrong.

There is a Unix command called "pwd" that returns the directory you're currently in (in a terminal). I did some searching and found that a library "unistd.h" existed with a function called "getcwd" that passed the current working directory to a character array. I printf'd that bad boy out and found where my program was looking (in one folder up in the tree). I copied my .plx file there and bam - working program.

So, huzzah Unix is the sentiment tonight!

No comments:

Post a Comment