Hey guys...writing a program (or, trying to

) for my CS class...I have it about 99% done, but I can't get one nagging detail right.
What I need to do is read data from a file into parallel arrays, which are declared as:
Code:
string Brand[MAX_COMPUTER];
short RAM[MAX_COMPUTER];
where MAX_COMPUTER is a global constant. Ok. Now, the file can have any number of entries in it, including 0 to >MAX_COMPUTERS. I need to read up to and including the first MAX_COMPUTERS entries (each entry is on a new line) and nothing past that. However, I still need to accumulate a counter for entries > MAX_COMPUTER.
I tried something like:
Code:
{
short count = 0;
//open file
//check for proper opening
//file input stream is fin
fin >> Brand[count] >> RAM[count]
while (fin)
{
count++;
if (count <= MAX_COMPUTERS)
{
fin >> Brand[count] >> RAM[count];
}
}
fin.close();
return count;
}
Works fine for a file up to MAX_COMPUTERS, but throws Memory Access Violations for entries > MAX_COMPUTERS.
Any ideas? So close to done...
Thanks in advance.
PS: If anyone wants to whole code, just to see what I'm doing, I'll put it online.
Also, if you need to understand the problem more, or I don't explain it clearly enough, you can read about it at
http://www.cs.uky.edu/~ryan/CS215_F07/programs/1pgm.html