Here's my issue. I've been having trouble getting the Hello World to launch and stay open. The console seems to close and I'm encountering unexpected errors that didn't exist in my working code, and others that don't seem like they should exist in the existing code.
As a typical n00b, I'm biting off more than I can chew by trying to make users have to have some form of input to gather another message and go through it to reach the end. Example of how the final product would look/act:
Hey there, I'm Frank's computer, nice to meet you! I have an awesome secret to tell you, Press Enter to continue and see what it is!
User Input "Enter"
"I am going to explode in approximately ten minutes! I hope you do lots of cardio because you will need to run fast!"
I've just done the stupid thing however, and edited code that was already somewhat working, and now I cannot get it working again the way I want it (With the command not closing)
Here's what my broken mess of code looks like, be gentle, I'm already hurting.
string firstname = "";
cout << "Enter your first name and hit Enter:";
cin >> firstname;
cout << endl;
cout << "Hello, " << firstname << ", it is nice to meet you, I am Frank's CPU. I have something that I think is really neat. It's a secret! Hit Enter to find out! " << endl
cout << "Goodbye!";
cout << "Press ENTER to continue..."
cin.ignore( numeric_limits <streamsize> ::max(), '\n');
}
In regards to the last section, when I try to compile and run with that, it says that I need ";" before the cases of cout and cin.ignore, turning the bottom section of code into:
;cout << "Goodbye!";
cout << "Press ENTER to continue..."
;cin.ignore( numeric_limits <streamsize> ::max(), '\n');
}
After I do that, however, I'm getting the error where the console closes on it's own, which I thought that the cin.ignore was supposed to thwart.
Anyways, thanks for any comments and help with this. Feel free to shoot me off an e-mail or send me a message with info for Skype or what have you if you're interested in helping out a little more personally and hands-on.
#include <iostream>
#include <string> // this is required
#include <limits>
usingnamespace std ;
int main ()
{
string firstname ;
cout << "Enter your first name and hit Enter:";
cin >> firstname;
cout << '\n' ;
cout << "Hello, " << firstname << ", it is nice to meet you, I am Frank's CPU.\n"
<< "I have something that I think is really neat.\n"
<< "It's a secret! Hit Enter to find out!\n"
<< "Goodbye!\n"
<< "Press ENTER to continue..." ;
cin.ignore( numeric_limits <streamsize> ::max(), '\n');
std::cin.get() ; // wait for the user to press enter
}
I get this meow, however what about using the namespace?
Also, just for my own knowledge, at the end for:
std::cin get() ;
If I'm using the std namespace then why does it matter if I have std there? I tried running it without and it wasn't working at all.
What is the process that's happening there?
I'm a much better learner if I know the going-ons and the how-it-duzzits than with just the knowledge (So far, FYI, you guys have been more helpful with clarification than previous research. Thanks for that! :) )