Original Post
Hello all i have a program that i have just finished and everything works except for the below function. It will only load the name from the first object in the array then it reads blank for the rest. However i have tried using "cout << classone.name;" after "classone[i].name[c]=namebuff[c];" and it outputs all of the letters in the file.... I am truley confused. If a more experienced coder could look at this and give me some advice i would be very greatful. If you need the namerec.dat file i can send it to you. It was created by writing a string of names seperated by "1"''s and ended with "1" "0" into a file using ofstream. so an example string would look like this.
"bob1stu1john1cameron10"
now heres the function. Everything is declared localy so you dont need to worry about any other vars.
void loadname();
void loadname()
{
char namebuff[400];
infile.open("namerec.dat",ios::in);
infile >> namebuff;
infile.close();
int c=0;
char d[]="0";
char e[]="1";
int i=0;
while(namebuff[c]!= *d)
{
classone[i].name[c]=namebuff[c];
c++;
if(namebuff[c]== *e)
{
c++;
i++;
}
}
}
if you want to email me to get more info or the namerec.dat file my address is racerx@programmer.net
Thanks
Eric