Saturday, March 26, 2011

fiddling

I made some structural changes to my file reader. I'm trying to get each data type extraction into its own function - I have one down, two to go. What's funny is that I actually used some (what I consider to be) advanced pointer usage almost without thinking.

I create a FILE pointer almost first thing in main(), and then each function for extracting a data type uses that pointer so I need to pass the function that pointer.

The prototype looks like:

getdata(FILE**)

and in main() I have:

FILE *file;
getdata(&file);

and then in the getdata() function I remembered to dereference the local FILE** to get to my FILE pointer in main().

Not a big deal, but there were about a dozen posts last summer about trouble with passing pointers to functions.

I got that working well enough and moved on to a "sanity check" project. There is a neat tool called GNUPlot, and someone made an ANSI C front end called gnuplot_i. It basically gives you a bunch of functions to call from C and then it does the rest. To use it you first compile the gnuplot_i.c program to gnuplot_i.o, and then link any C program using the functions against that. I can do this from the command line, but doing it through XCode fails. I'm not sure why - I'll try Eclipse tomorrow.

No comments:

Post a Comment