How to store same type structs in an array.

Pages: 12
@LowestOne

OK, how does one go about finding out how one's compiler implements various bits of the STL?

Cheers in advance !
@OP - You have a problem with nameCheck and numberOfStudents.

If your edit check fails, you make a recursive call to the same function. That would work, but you're not returning the value from the nested call. i.e. If the first name you enter is longer than 30, you make a recursive call. If the second attempt is valid, the nested call will return a valid name, but that name is lost and the outer call will return an empty string.

IMO, using recursion for an edit check is poor style and not an appropriate use of recursion. I can't tell from the code you posted if you have been introduced to do {} while () loops.

A better example of nameCheck would be:
1
2
3
4
5
6
7
8
string nameCheck()
{  string name;
    do 
    {    cin >> name;
    }
    while (name.length() > 30);
    return name;
}


edit: You might also want to check that the length of the name is greater than 0, assuming that a name is required.


Last edited on
@TheIdeasMan
how does one go about finding out how one's compiler implements various bits of the STL?

Take a look at the various header files. If you want to find out how vector works, find the <vector> header file and take a look at it.



Topic archived. No new replies allowed.
Pages: 12