Please help
What I'm basically trying to do is load data from a file into a few parallel arrays. I'm using Borland.
Here is my code:
string nameSet[20];
int ageSet[20];
char sexSet[20];
double incomeSet[20];
int index;
ifstream fin("h:\\date.dat");
if(!fin)
{
cout<<"no date file";
system("pause");
exit(-1);
}
for (index = 0; index < 20; index++)
fin>>nameSet[index];
for (index = 0; index < 20; index++)
fin>>ageSet[index];
for (index = 0; index < 20; index++)
fin>>sexSet[index];
for (index = 0; index < 20; index++)
fin>>incomeSet[index];
Does this look right to you? It worked at first but then wierd things started happening later on. For example, I'd get a wierd pop up that says CPU plus what appears to be some memory addresses. I don't think that there's any way that my array is out of bounds so I'm just confused as to why this is happening.
Does anyone have any ideas? (By the way this is my first time taking C++ so please bear with me)
Thank you :)
Here is my code:
string nameSet[20];
int ageSet[20];
char sexSet[20];
double incomeSet[20];
int index;
ifstream fin("h:\\date.dat");
if(!fin)
{
cout<<"no date file";
system("pause");
exit(-1);
}
for (index = 0; index < 20; index++)
fin>>nameSet[index];
for (index = 0; index < 20; index++)
fin>>ageSet[index];
for (index = 0; index < 20; index++)
fin>>sexSet[index];
for (index = 0; index < 20; index++)
fin>>incomeSet[index];
Does this look right to you? It worked at first but then wierd things started happening later on. For example, I'd get a wierd pop up that says CPU plus what appears to be some memory addresses. I don't think that there's any way that my array is out of bounds so I'm just confused as to why this is happening.
Does anyone have any ideas? (By the way this is my first time taking C++ so please bear with me)
Thank you :)
