![]() |
|
#1
|
|||
|
|||
Help with survey programYea im trying to make a christmas survey program for my class project, Im using strings to set 20 variables, Not a experienced programmer this is my first year in classes just trying to learn and need a bit of help. my program wont even do anything it says no errors, runs then says press any key to continue.. Any help someone can offer would be greatly appreciated
CPP / C++ / C Code:
Last edited by JdS : 30-Nov-2006 at 20:03.
Reason: Please insert your C code between [cpp] & [/cpp] tags
|
|
#2
|
|||
|
|||
Re: help with survey programQuote:
1. The following is illegal. I can't believe any C++ compiler accepted it: CPP / C++ / C Code:
How about this: CPP / C++ / C Code:
Two ans15 declarations? I don't believe any compiler would accept that. Be sure and post the code that you actually used. And if there were compiler messages, post them also. 2. When you use cin>> with a string, it only reads one word, so if you enter "hot chocolate" in response to that question, it only reads "hot" into ans1, and puts "chocolate" into ans2 (without waiting for your response to the next question). Why not use getline() for everything? 3. I think it's a good idea, especially for new programmers, to make the program print out what it is working on whenever it gets user input. That way you know whether it is working or not: CPP / C++ / C Code:
You can always remove (or comment out) the extra cout statements later. Regards, Dave |
|
#3
|
|||
|
|||
Re: help with survey programAllright I played around with everything fixed my small errors; and I got it running but the problem im experiencing now well heres the code
Code:
Code:
|
|
#4
|
|||
|
|||
Re: help with survey programQuote:
This line certainly has an error, and one thing that I personally guarantee is that the error messages are not random. They may be inscrutable but they are not random. My point is that you should post the exact error messages. If there were 45 messages, don't post all of them, just the first few. I promise you that the error messages will "involve" your code. There may be other errors, but I respectfully suggest you post the exact messages that point out this line. Once you see how to get to the bottom of things, then that becomes part of your life experience in the wonderful world of debugging, and you will have a good chance of recognizing the relevance if you ever see this kind of message again. Regards, Dave |
|
#5
|
|||
|
|||
Re: help with survey programCode:
|
|
#6
|
|||
|
|||
Re: help with survey programQuote:
That's why I wanted to see the exact error. You have to learn to look carefully. I can't see why there would be lots and lots of errors, so I'll just concentrate on the first ones (the ones that you posted): It is telling you that there is a problem with your use of the operator '>>'. Specifically, on line 96 of your code. Here: I will filter the fly specks out of the pepper: Code:
So, look at line 96 of your code and see if there is anything wrong that might involve '>>' CPP / C++ / C Code:
I know that it is very unnerving to see pages and pages of error messages that are seemingly irrelevant, but learning to zero in on the problem is a very important part of programming. No one was born knowing this stuff: it's a learning process. Now fix that line. Fix it. Don't worry about all of the other errors, just fix it. Then try to compile again. Regards, Dave Footnote: Another little debugging hint: If it used to work and you changed it, then look carefully at the changes. Comment out some of the stuff that you changed; see if that affects the error messages. (One thing that might result is that you might consider a development strategy that only changes a few things at a time and compiling incrementally. Maybe even executing and testing before making massive changes.) Last edited by davekw7x : 01-Dec-2006 at 10:01.
|
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Text-Based Roulette Game | mfm1983 | C++ Forum | 5 | 29-Nov-2006 12:20 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 03:48 |
| How to read particular memory location ? | realnapster | C Programming Language | 10 | 10-May-2006 09:11 |
| Type casts ? | kai85 | C++ Forum | 12 | 23-Jun-2005 12:04 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The