Monday, September 27, 2010

The wrong way

Well, my original intention was to show how variables declared in functions, including pointers, would be destroyed after the a function returned, but now I'm hitting new problems.

I wanted to compartmentalize the loading of the file because it would make this code a bit more portable - I could just copy the functions I needed to the next iteration of what I'm working on. I really don't want to load the file in the main part of the loop because I'd only be able to do it once. What if I wanted to close the file and load a different one without restarting the program. I can think of a way to do this without having functions for doing it, but I'd rather do it this way to practice. I could just pass arguments to the function that said whether or not to reload on or whatever.

I actually "discovered" pointers to pointers by drawing it out and realized "boy it would be nice if I could have a pointer to a pointer". It probably isn't the right solution to this problem, but we'll see.

No comments:

Post a Comment