Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
in c++ how do you combine code like

Hello
press any button to continue

How are you doing?
press any button to continue

and so on



PLEASE HELP!
Posted
Updated 29-Apr-11 17:41pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Apr-11 21:13pm    
This is beyond the good and evil!
--SA
Hans Dietrich 29-Apr-11 23:50pm    
I look at it as *before* the good and evil.

I mean, there was a time when I didn't know what ASCII was. I know, I know; a little removed from COM interfaces and .NET interop. I'm not even sure if there are any articles on CodeProject that would help the OP. And if there were, they would probably be downvoted out the wazoo, what with our lovely voting system.
Sergey Alexandrovich Kryukov 30-Apr-11 0:04am    
The problem is not voting or even CodeProject level or a student's level. I know pretty well how people who did not yet get what is a variable or function is, how they think of things and try to learn. You know, I find most of them reasonable enough. They mostly adequately evaluate their knowledge and are able to ask comprehensible questions which worse answering. What we see here is something else...
--SA
Hans Dietrich 30-Apr-11 0:27am    
I agree. This is a level of knowledge that comes before questions such as, How do I play a WAV file? We were all here at one point, so we shouldn't be surprised to find others here now. :)
Sergey Alexandrovich Kryukov 30-Apr-11 1:25am    
I was always amazed why so many people (except those familiar with mathematics and the idea of "proof", "axiom", etc.) think that real-life statements are classified just into "true" and "false", failing to understand that there is one more class (again in real-life language) which can be called "makes no sense". Failing to recognize such thing usually leads to making a lot of statements from this third class :-)

Same story with questions.
I'm very afraid to say so, but often the same story with "functional requirements". :-<
--SA

This is a wild guess, but if you mean how do you pause for a key stroke, then look up _getch on MSDN.

http://msdn.microsoft.com/en-us/library/078sfkak(v=VS.100).aspx[^]
 
Share this answer
 
Comments
Albert Holguin 30-Apr-11 14:19pm    
my 5
What you are asking about is a type of man-machine interface. In human communications, when you say Hello, you pause to wait for the other person to respond. In the same way, there are two steps involved in constructing an interface with a computer:

1. Output (display) a string, such as Hello.

2. Wait for a response; a keystroke, or a string, or some kind of user selection.

On PCs running Windows or Unix/Linux, there is a standard library of functions that allow you to do these two things. It is called the "C RunTime", or CRT for short.

Using CRT functions, it is possible to do what you are asking about. We use the CRT function "puts" to display a string, and then use the CRT function "_getch" to wait for a keystroke (a "button" as you call it).

We can repeat these two steps as many times as we want.

The following code can be pasted into a Visual Studio project and compiled if you would like to see it in action:
// console1.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <conio.h>

int main(int argc, char* argv[])
{
	// ask the first question
	puts("Hello\n");
	puts("Press any button to continue...\n");

	// wait for key press
	_getch();

	// ask the next question
	puts("How are you doing?\n");
	puts("Press any button to continue...\n");

	// wait for key press
	_getch();

	// etc.

	return 0;
}
 
Share this answer
 
v3
Comments
Albert Holguin 30-Apr-11 14:19pm    
Hard to interpret what the OP wants, but this may be it... my 5 :)
Hans Dietrich 30-Apr-11 15:32pm    
Thanks.

Some people would associate lack of knowledge with being stupid, but I am willing to believe this was an honest question, from someone with little exposure to the subject. There's no reason not to encourage people like this.
Albert Holguin 30-Apr-11 20:46pm    
I didn't call him stupid, just hard to interpret what he wants (not a well phrased question). :)
Hans Dietrich 30-Apr-11 21:26pm    
I know you didn't; but from the 1-votes other people obviously thought that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900