C++ Do while problem
Hello everyone,
this is what my program is supposed to do: initially prompts the user for the area code. Then the program continuously accepts phone call data, and displays data for any phone call to or from the specified area code. The program ends when -1 is input for the area code. Code:
#include <iostream> any thoughts? |
Quote:
In fact, even doing this for yourself (before you contact the forum) is a good way to get a handle on the problem. |
Code:
while (custAreaCode = -1); Code:
if (custAreaCode = -1){ |
Maligree explained the major bug, but you should also look at
Quote:
I don't think your code does what you intend. |
The compiler compiles as it has to do because there are not syntax problems and it does its job, but you wronged the symbols, you seem confused about the sign " = " and the sign " == " and wronging these symbols you won't get any error if not logic ones and wrong results ;) Correct the symbols, it might work.
|
Quote:
|
I did not look at the whole program before, just found those (obvious) comparison/assignment bugs. Even now, I'm not going to fix the whole thing, since a) I don't know how it is supposed to work and b) I'm not really into doing other peoples' homework.
Anyway, the structure is really wrong. I can't even elaborate, the use of that do { } while is.. *cough*. And at the end you prompt for more data and just discard it.* All in all, I guess you should really read up on how loops and conditional checks work. *- reminds me of "What does your robot do?" "It collects data about the surrounding environment, then discards it and drives into walls". |
All times are GMT -5. The time now is 06:23 AM. |