954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dev-C++ Question

I am trying to get something to print to my screen aftre i type in the source code. Eveytime i compile and run it it just flashes a dos screen real fast and goes away. How can I see what it is printing to the screen. If anyone can help me i would greatly appreciate it.

scott_6169
Newbie Poster
13 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

>If anyone can help me i would greatly appreciate it.
Sure .

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 
How can I see what it is printing to the screen.


try going to your dos window first, navigating to the appropriate directory and then running your .exe. Or open a dos window and type in full name and path of your .exe

BlackDice
Light Poster
43 posts since Apr 2004
Reputation Points: 19
Solved Threads: 0
 
I am trying to get something to print to my screen aftre i type in the source code. Eveytime i compile and run it it just flashes a dos screen real fast and goes away. How can I see what it is printing to the screen. If anyone can help me i would greatly appreciate it.

I think you have to add a line of code like

system("pause");

at the point you want to pause the screen.

lakessler1
Newbie Poster
2 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

I tried to open the dos screen first and then type it in and it still says i have have an error in the log or something i just simply want to see what it does when i go to run it. I cannot get it to print to the screen. i am very greatful for your help

try going to your dos window first, navigating to the appropriate directory and then running your .exe. Or open a dos window and type in full name and path of your .exe
scott_6169
Newbie Poster
13 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

I tried to type in the system("pause") and that was not working. My professor said something about a scanf stopping it or something. Do you know what he means by that? Again thank you for your help

I think you have to add a line of code like

system("pause");

at the point you want to pause the screen.

scott_6169
Newbie Poster
13 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 
>If anyone can help me i would greatly appreciate it. Sure .

When you follow this link, there is another link on that page: How do I get my program to wait for a keypress?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Thank you Dave. I really do appreciate it. This is so stressful and i have no help so your help is greatly appreciated. I have never programed a day in my life and this is the only reference i have. Do you have anymore suggestions for me??

When you follow this link, there is another link on that page: How do I get my program to wait for a keypress?
scott_6169
Newbie Poster
13 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

So how would I get this to print to my screen without the dos prompt going away really fast? I know i am probably asking stupid questions but I am really trying to understand this

#include

int main()
{
("Hey,you,I'm alive! Oh, and Hello World!");
}

Thank you Dave. I really do appreciate it. This is so stressful and i have no help so your help is greatly appreciated. I have never programed a day in my life and this is the only reference i have. Do you have anymore suggestions for me??
scott_6169
Newbie Poster
13 posts since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

>So how would I get this to print to my screen without the dos prompt going away really fast?

#include <stdio.h>
 
 int main(void)
 {
 	puts("Hey,you,I'm alive! Oh, and Hello World!");
 	/* insert code to wait for user input */
 	fputs("Press enter to continue...", stdout);
 	getchar();
 	return 0;
 }
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

There is another way that I do it and I had the same exact problem as you did. You want to use the getch() function. I assume you are not to concerned with the amount of memory it uses its only around 75 k.

#include
#include
#include

void main()
{
cout<<"Hey,you,I'm alive! Oh, and Hello World";
getch(); //this terminates the program when you hit enter
}

I have the same exact compiler so if you need any help post a message to me.

caffiene_junky
Newbie Poster
3 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

>You want to use the getch() function.

There is not much reason to use a nonstandard function when there is a standard one that can do much the same.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Add a line
system("pause");
before you enter
return 0;

Ghazanfar Ali
Newbie Poster
2 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You