Another beginner question DevC++

I

IS

I'm using BloodShed DevC++. If you know the program that would be great.

Here is what I'm doing:
File>New>Source File.

Then I enter:

#include <iostream.h>

int main();
int main()
{
cout <<"Hello World!/n";
}

Next I click Save As and name the file "Hello World"

Then I go to Execute and click "Compile". When its done I go back to
Execute and click "Run".

After I click "Run" I only get a split second Command Prompt (Using XP Home)
flashing on my screen. Way too fast for me to even see if there's anything
there.

Am I doing something wrong? . . Or missing some steps?

Thanks.

IS.
 
G

Gregg

I'm using BloodShed DevC++. If you know the program that would be
great.

Here is what I'm doing:
File>New>Source File.

Then I enter:

#include <iostream.h>

This is non-standard. You should use

#include said:
int main();

This is not necessary.
int main()
{
cout <<"Hello World!/n";
}

You should use

std::cout << "Hello World!/n";
Next I click Save As and name the file "Hello World"

Then I go to Execute and click "Compile". When its done I go back to
Execute and click "Run".

After I click "Run" I only get a split second Command Prompt (Using XP
Home) flashing on my screen. Way too fast for me to even see if
there's anything there.

That's because Windows arranges to display a console window (what you
call a command prompt) only for as long as the program is running. As
soon as the program is finished, the window will go away. So you have two
choices. Either add a statement to wait for the user to press the enter
key before exiting, or open a command window yourself, and run the
program directly instead of from the environment. You can wait for user
input by adding

std::cin.get();

after the cout statement.

Gregg
 
G

Gregg

cout <<"Hello World!/n";

You also are using a forward slash where you should be using a backslash. I
incorrectly copied this error in my previous reply. It should be

std::cout << "Hello World!\n";

Gregg
 
K

Karthik Kumar

IS said:
I'm using BloodShed DevC++. If you know the program that would be great.

Here is what I'm doing:
File>New>Source File.

Then I enter:

#include <iostream.h>

int main();
int main()
{
cout <<"Hello World!/n";
}

#include <iostream>
#include <cstdlib>

int main()
{
std::cout <<"Hello World!\n";
return EXIT_SUCCESS;
}

Next I click Save As and name the file "Hello World"

Then I go to Execute and click "Compile". When its done I go back to
Execute and click "Run".

After I click "Run" I only get a split second Command Prompt (Using XP Home)
flashing on my screen. Way too fast for me to even see if there's anything
there.

Am I doing something wrong? . . Or missing some steps?

As such this is O.T since we dont discuss the IDE / implementation
stuff here. But then, you can fix the problem you had mentioned by
inserting a system("pause") command ..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,949
Members
47,500
Latest member
ArianneJsb

Latest Threads

Top