English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Ok this is the same as my last question...although I'm sure much of the content was deleted because of the charater limit...Please click on the link to view my project. 10 points and my respect go to the person that can give me a hand.

http://www.geocities.com/youmember2001/beta2.txt

2006-11-30 14:22:46 · 3 answers · asked by D 4 in Computers & Internet Programming & Design

I am seriously mind boggled at what is wrong with my program, I marked the comments where this error occurs. I've spend the last 4 hours making it, so I can't really think clear right now, from what it looks like, for some ODD reason that I fail to see right now, my program enters a fail safe after the marked line. This is extremly odd being as if I use the standard extraction operator cin >> the damn thing works, BUT I cannot USE the standard extraction operator. Anyway, I marked comments with a <= Marker, if you take both of them off, the program will ALMOST work. Anyone that can at LEAST figure out why this is not working, will earn 10 points, and my respect.

Please do not tell me simply to change the variable type to char, at least without explaining why it wont work.

2006-11-30 14:26:53 · update #1

This is a RUN time error, not a compile error...

2006-11-30 14:42:07 · update #2

assert is only an undeclared identifier because I had the pre processor directive deleted by accident, this is not the problem. #include will fix the compiler error, the problem I am having is NOT a compile error, it is a RUN time error.

I have also marked where the error occurs.

2006-11-30 15:08:07 · update #3

3 answers

See my answer to your other question.

http://answers.yahoo.com/question/index;_ylt=AgeLT6aCx2WWAMVMhfVgxgPsy6IX?qid=20061130195144AAJCJla

2006-12-01 07:01:38 · answer #1 · answered by Kookiemon 6 · 0 0

Ok, the problem is that when the user enter it's selection from the menu, he type a letter then a return.

But the program only read ONE character from the stream, letting the return character in it.

So when you try to read the name with a getline, it encounter a return in the stream, and this is the end of the line. But nothing have been read...

So to correct this, use a getline when reading the option from the menu, and then consider only the first character read. That way the stream will be empty and ready for a getline when you are ready to read in the name.

void Insert(nodeType* &Head,nodeType* &Last)
{
//Declare local variables
nodeType *NewNode = new nodeType;
string Value = "";
char szString[256] = {0};
int GoodData = 1;
//<--char temp; Take off <-- marked comments and it almost works???
while (GoodData == 1)
{

cout << "Please enter full name (EX LastName FirstName) " << endl;
//<--cin >> temp; //***ALMOST WORKS WITH A CHAR???
cin.getline(szString, 255); //ERROR, Program Enters fail state???
if (static_cast(Value.length()) > 20)
cout << "TOTAL NAME MUST BE 20 CHARACTERS OR LESS!!!!!! " << endl;
else
GoodData = 0;
}

....

2006-11-30 15:48:55 · answer #2 · answered by Yoda Miyagi 4 · 1 0

Your error is in line 92.
assert...undeclared identifier.

2006-11-30 15:04:34 · answer #3 · answered by selfrob 4 · 0 0

fedest.com, questions and answers