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

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

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

to change the variable type to char, at least without explaining why it wont work.


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

2006-11-30 14:52:06 · update #1

3 answers

You have a return character leaking over in the input stream from when you make your Choice. If you change this line

cout << endl << "Your choice=> " << Choice << endl;

to

cout << endl << "Your choice=> " << Choice << endl;
cin.ignore(1);

It will remove the return character. There's probably a better way to handle this type of problem, but my mind is fuzzy at the moment.

Fixing that problem, you are presented with another problem of removing names with spaces in it from your list. To fix that use

getline( cin, Value);

instead of

cin >> Value;

in your Remove function. The latter piece of code places a null character at the first space it sees in the input stream which you don't want. The former correctly places the entire string into Value.

2006-11-30 20:55:36 · answer #1 · answered by Kookiemon 6 · 0 0

I think the issue may be that the variable value, declared as string, was assigned "", which gives it length 0. So, using this string with cin overwrites the other variables on the stack, which explains why adding that char makes a difference.

Try declaring the string with length 255 and see if things get better.

2006-11-30 23:42:28 · answer #2 · answered by arbeit 4 · 0 0

It looks like the problem is with using "cin" in the getline function. When I run the program, it runs without error, but the nodes that were inserted with the Insert function are blank.
-------------
OK, look, you do not need to do cin to a char. You can do cin to a string!
Just replace the
getline(cin, Value);
with
cin >> Value;

2006-12-01 00:25:37 · answer #3 · answered by DadOnline 6 · 0 0

fedest.com, questions and answers