Newbie questions on very basic program

P

pauldepstein

On Bloodshed Dev using Windows XP, I'm trying to run the program:

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{

system("PAUSE");
cout << "this";
return 0;
}

I know that I shouldn't use "PAUSE" and maybe I shouldn't use standard
namespaces etc.

However, I have a more basic issue. I don't get any visible output on
my screen. Why do I not see the word "this" on my screen?

Probably the word "this" just flashes for a millisecond or less.
Anyway, I want to get the word "this" on my screen.

A more complex question: What are some techniques for the following
type of problem: Someone presents some source code and the question is
asked: "How much memory does this program take?" How does one
calculate memory allocation? What is a good website for this type of
problem?

Paul Epstein
 
J

Jim Langston

On Bloodshed Dev using Windows XP, I'm trying to run the program:

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{

system("PAUSE");
cout << "this";
return 0;
}

I know that I shouldn't use "PAUSE" and maybe I shouldn't use standard
namespaces etc.

However, I have a more basic issue. I don't get any visible output on
my screen. Why do I not see the word "this" on my screen?

Probably the word "this" just flashes for a millisecond or less.
Anyway, I want to get the word "this" on my screen.

A more complex question: What are some techniques for the following
type of problem: Someone presents some source code and the question is
asked: "How much memory does this program take?" How does one
calculate memory allocation? What is a good website for this type of
problem?

Paul Epstein

If the screen is closing too fast before you can see it, then you need to
get it to wait after you put the "this" there.

Instead of using the system("PAUSE") I use this code:

std::string wait;
std::cin >> wait;

If you put that after the
cout << "this";
and include <string> then you should see the "this".

Or put another system("PAUSE") after you output "this"

I don't know what Bloodshed dev is, but I know that microsoft visual c++
..net 2003 has this issue when I run a program by pressing F5, closing
immediately. If I run the program by pressing ctrl-F5 then the output box
waits til I press a key before closing.
 
M

Mark P

On Bloodshed Dev using Windows XP, I'm trying to run the program:

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{

system("PAUSE");
cout << "this";
return 0;
}

I know that I shouldn't use "PAUSE" and maybe I shouldn't use standard
namespaces etc.

However, I have a more basic issue. I don't get any visible output on
my screen. Why do I not see the word "this" on my screen?

Probably the word "this" just flashes for a millisecond or less.
Anyway, I want to get the word "this" on my screen.

Put the code *before* the system("PAUSE") statement.

Mark
 
D

Daniel T.

On Bloodshed Dev using Windows XP, I'm trying to run the program:

#include <iostream>
#include <stdlib.h>

the above line should read: #include said:
using namespace std;

int main()
{

system("PAUSE");
cout << "this";

Try reversing the above two lines.
return 0;
}

I know that I shouldn't use "PAUSE" and maybe I shouldn't use standard
namespaces etc.

However, I have a more basic issue. I don't get any visible output on
my screen. Why do I not see the word "this" on my screen?

Probably the word "this" just flashes for a millisecond or less.
Anyway, I want to get the word "this" on my screen.

A more complex question: What are some techniques for the following
type of problem: Someone presents some source code and the question is
asked: "How much memory does this program take?" How does one
calculate memory allocation? What is a good website for this type of
problem?

Don't worry about it unless you are programming for an embedded system.
If you are doing that, then the systems API will have functions for
calculating memory consumption issues.
 

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
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top