1

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.

6
Contributors
12
Replies
13
Views
13 Years
Discussion Span
Last Post by Ghazanfar Ali
Featured Replies
  • >If anyone can help me i would greatly appreciate it. [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385"]Sure[/url]. Read More

1

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

1

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.

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

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.

0

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?

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 <stdio.h>

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??

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;
 }
0

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 <conio.h>
#include <stdio.h>
#include <iostream.h>

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.

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.