Quote Originally Posted by zacs7 View Post
1. Don't use feof() to control a loop (see the FAQ)
2. fscanf(cfPtr, "%s", fileData[linesRead]); is a serious potential buffer overflow. What if %s is larger than fileData[linesRead]?

3.
Code:
char **fileData;
fileData = malloc(20);
Remember we're dealing with char pointers now (ie pointers to pointers to chars). You can however, do:

Code:
char * fatArray = malloc(20 * 10);   /* ie, char example[20][10]; */
Then treat it as an array, or you can do it the old fashion way , allocate room for 20 char pointers, then allocated 10 characters each that the pointers will point to respectively.
PS: I love MIPS
Ty zacs!

I actually caught in another thread about feof causing problems, and I did read the faq. I'm not sure I have time to implement it though, and I do know within a range of tolerance what I'll be reading in for this project, so converting it is on my list of things I want to do if I have enough time.

If you find yourself with a moment, could you tell me what is actually happening behind the scenes with the (20 * 10)? Is it mallocing 20 indexs to sets of 10 indexs? I'm just curious because I don't have a good grasp on malloc unfortunately, I understanding it's allocating a region of memory in the size of the passed parameter, but I'm really fuzzy on how it's handling the 2d arrays. Is this just basically a different syntax to 2d array creation?

I'm also enjoying MIPS, I originally hated it in my lower(Basic) assembly course when it was really confusing, but now that I'm in upper-level courses it's making sense and I'm finding it's potential interesting. Especially now that I'm learning about data hazards and finding myself wondering if small changes in coding practice can yield significant changes in performance if I think about what happens at low levels with pipelines.

I swear, once I have some free time on Thanksgiving, I'm writing programs in different ways to see if they yield different performance!