C++ coding help plz!
basilmarket.com forums :
Tech Talk
| 14 posts archived
thread starter asand200 Jul 31 2009
+ PM | QUOTE | PERMALINK | REPORT
| Im trying to make my very own code so i need some help im just started learning so sry for all the noobishness o.o When i run my code it starts off like this "Did it work?" ( I enter "Y" for yes here) then all I want is "ok good!" but instead of that all of the other things come up at once! here is my code help plz if i made any sense o.o #include <iostream> using namespace std; int main () { char question; cout << "Did it work ?" << endl; cin >> question; cout << "Okay good! " << endl; cin >> question; cout << "Would you like to continue?" << endl; cin >> question; cout << "your mission is to defeat the black magaician!" << endl; cin >> question; cout << "You have to first head off to Sleepywood to find his follower The Puppeteer!" << endl; system ("pause"); return 0; } Sry for the cheap questions i couldnt think of anything atm >.< |
MagicSheepz 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| Are you trying to make a PS? |
ponjoe 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| Try -int #include <iostream> using namespace std; -intmain () { cout <<"Did it work"; return 0; } |
Takeback3r Jul 31 2009
+ PM | QUOTE | PERMALINK | REPORT
| #include <iostream> using namespace std; int main () { cout <<"Did it work"; return 0; } The bolded is probably what will fix it. @ above: Read the error message. "Note: C++ does not support -int" |
OneHope 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| #include <iostream> using namespace std; int main () { cout <<"Did it work"; return 0; } ... that should fix it up. |
asand200 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| ok i did #include <iostream> using namespace std; int main () { cout <<"Did it work"; return 0; } ______________________________________________________________________________________________________________________________ it gives me this thing now ______________________________________________________________________________________________________________________________ 1>------ Build started: Project: Aaron, Configuration: Debug Win32 ------ 1>Compiling... 1>1.cpp 1>Linking... 1>Embedding manifest... 1>Build log was saved at "file://c:UsersAaronDocumentsVisual Studio 2008ProjectsAaronAaronDebugBuildLog.htm" 1>Aaron - 0 error(s), 0 warning(s) ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== |
sleepyxdude 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
 | asand200 said: "ok i did #include <iostream> using namespace std; int main () { cout <<"Did it work"; return 0; } ______________________________________________________________________________________________________________________________ it gives me this thing now ______________________________________________________________________________________________________________________________ 1>------ Build started: Project: Aaron, Configuration: Debug Win32 ------ 1>Compiling... 1>1.cpp 1>Linking... 1>Embedding manifest... 1>Build log was saved at "file://c:UsersAaronDocumentsVisual Studio 2008ProjectsAaronAaronDebugBuildLog.htm" 1>Aaron - 0 error(s), 0 warning(s) ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========" That means it compiled correctly so just run it |
asand200 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
DownTown 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| I gave up on programming after a while. Too complicated x_x |
redhades777 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
 | c++ is one of the worst languages to learn programming with. build up your logic with an easier language, then come back to c++. |
asand200 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| Can some1 help me plz! =] |
MrPineapple 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| Yeah, as above I highly recommend starting with Basic C, then moving up to C++, C#, Java or whatever. Or at least have a mild understanding of basic syntax, compiling and executing. I despise C++, the >> syntax needs to burn, it caused me so many pointless and time consuming errors. Evil. |
icemage07 Jul 31 2009
+ PM | QUOTE | PERMALINK | REPORT
| i tested your code and it seemed to work just fine. are you sure you're assigning a proper value for your char variable (during run-time)? note that if you assign more than 1 char to a char variable, the remaining chars stay in a "buffer" and are then assigned to the next variable(s). For example, let's say you typed in "mesos" (without the quotes) for your char variable. the first input for your char variable is "m", the remaining "esos" stay in the buffer, and are assigned to your next variables, one at a time. here's what would happen (the bold part is the input): (changed the code slightly to display the values, input is bolded) Did it work ? mesos mOkay good! eWould you like to continue? syour mission is to defeat the black magaician! oYou have to first head off to Sleepywood to find his follower The Puppeteer! Press any key to continue . . . |
nobrainer612 07/31/09
+ PM | QUOTE | PERMALINK | REPORT
| -Try to use "If" loop #include <iostream> using namespace std; int main () { int a,b; cout << "Did it work ? Please enter 1 for yes and 0 for no" << endl; cin >> a; if(a==1){ cout << "Okay good! " << endl; cout << "your mission is to defeat the black magaician!" << endl; cout << "You have to first head off to Sleepywood to find his follower The Puppeteer!" << endl; }else { cout << "Would you like to continue? Please enter 1 for yes and 0 for no" << endl; cin >> b; if(b==1){ cout << "your mission is to defeat the black magaician!" << endl; cout << "You have to first head off to Sleepywood to find his follower The Puppeteer!" << endl; } system ("pause"); return 0; } ------------------------------------------------------------------------------------------------------------------- so this script will basically continue to run as you enter 1 for yes, and will end if you enter 0 |
BasilMarket is Copyright 2004-2008 BasilMarket.com (archive reconstruction). Data recovered from the Internet Archive Wayback Machine for the Classic MapleStory community.