| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
newbie got a fudgin problem!
this is the code
//--------------------------------------------------------------------------- // my first program in C++ #include <iostream> using namespace std; int main () { cout << "Hello World!"; return 0; cin.get(); } and when i run it it opens a new black window with no words but it only opens just for a sec cause then it closes and i have no idea what this mean so yeah some help |
|
#2
|
||||
|
||||
|
Ok this is one newb to another but just try this. Ill leave comments like this // blah blah comments =Þ
Code:
#include <iostream>
using namespace std;
int main (void)//main program code
{
int answer;//answer is just an example, can be anything...
cout<<"Hello World";
cin>>answer;//this will pause the program until a number is entered...
}
you can do this or you can just drop the return 0; before the cin.get() =Þ which ever will work fine, all in how you want to do it though. |
|
#3
|
|||
|
|||
|
Quote:
I can use code : #include<iostream.h> void main() { cout<<"HELLO WORLD !" cin.get(); } |
|
#4
|
|||
|
|||
|
Wow thanks both u you finally it works with no errors thanks a lot!
I would give u both 20 dollars if u knew u guys |
|
#5
|
||||
|
||||
|
=Þ you can email me it lol
|
|
#6
|
|||
|
|||
|
you still need a return 0; after the cin.get()
|
|
#7
|
||||
|
||||
|
Quote:
Look at the order of your code. You have "cout" followed by "return" followed by "cin.get". First, it will print text to the screen, then the function will end, then it will be paused to wait for input. But your problem is, you're already exited the function before the pause command. Switch the order of "return" and "cin.get" ![]()
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > newbie got a fudgin problem! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|