i can't figure out how to solve this error, i've searched online, but any solutions i've found use terms that are beyond me (as i am still a beginner at C++)..so it's been a little tricky to crack this. basically all i'm trying to do here is find the length of newPin, and check to make sure this length is equal to 4. if there's any other way to accomplish this, that'd be great. but otherwise, if there is an easy solution here, i'd love to see it. so here's a snippet of my code and the lovely error that accompanies it.

string GetNewPin(string) {
do {
cout << "Enter new PIN number: ";
cin >> newPin;
} while(int(newPin.length) != 4);
return newPin;
}

h:\pa4\part2.cpp(98): error C2228: left of '.length' must have class/struct/union type

while(int(newPin.length) != 4);

should be

while( newPin.length() != 4); // length() is a memberfunction of string

K.

ahh.. it didn't work now that i tested it; i still get the same error, along with 16 new ones. :sad: oh well, thanks anyway.

sorry about all the posts.. i messed around a little more, and changed a few things elsewhere in the program, and tried your line again, which took the error off, thus your solution was correct. i probably still won't finish this project, but at least now i can get it in without errors! thanks again, Zuk.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.