It would be much easier to just do
cout << "whatever you put here"<< endl;
cin >> whatever u named it;
You couldnt put a semicolon after int main because thats not a line of code really...same thing with cin im terrible at explaining..
I need just a little help getting started.. I'm understanding most of it *not that I'm far or anything*. But I don't get the braces.
#include <iostream>
using namespace std;
int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
cin.get();
}
Why couldn't I use a semicolon after int main and cin.get... Instead of using the braces.. Is it because int main is a function thus requires the braces.. And cin.get is that because its a function, but why does it have the semicolon then if its already ended. I actually get the rest of that...cout...#include <iostream>..etc...
I know I'm a complete newb, but hey we all had to start somewhere, and this tut. does seem pretty good just isn't quite clear on this.
It would be much easier to just do
cout << "whatever you put here"<< endl;
cin >> whatever u named it;
You couldnt put a semicolon after int main because thats not a line of code really...same thing with cin im terrible at explaining..
Last edited by skittlznick2; 08-02-2008 at 07:03 PM.
The code I use for (Hello World):
(Remember I was using the CLR Application)
Code:#include <iostream> using namespace std; int main (void) { Cout<<"Your message here!n"; system("PAUSE")' return 0; }
Um, i'm fairly new myself but { and } just mean start and end of a code block. int main() is indeed a function, it's the main function where all or most of your code will execute. More or less it's just a open and close to a funtction. The semicolen is there just as end each line in the function. Correct me if i'm wrong.
Last edited by Sinful; 08-06-2008 at 08:10 PM.
int main() is your function. the get() in cin.get() is some one elses function that you are calling. Think of the semi colons as representing different commands. I.e. cout << .... ; is the first command the computer executes then it goes right done that what next! ahhhhh cin.get(); do that nothing else? ok see ya!
Hoepfully that will clear things up I'm not too good at explaining things :P
im guessing you are using cin.get to wait for a user to press a key?
instead use:
orCode:getchar();
orCode:System("pause"); //outputs "Press a key to continue"
and use return 0; before the final bracket "}"Code:System("pause>nul"); //no output
Go to cplusplus.com - The C++ Resources Network and do their tutorials. That's where I learned it...