Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 29-Apr-11 15:56pm
PAMIPP300
Edited 29-Apr-11 18:41pm
v2
Comments
SAKryukov at 29-Apr-11 21:13pm
   
This is beyond the good and evil!
--SA
Hans Dietrich at 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.
SAKryukov at 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 at 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. :)
SAKryukov at 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
Karthik. A at 29-Apr-11 22:26pm
   
@SA - nice one!!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Comments
Albert Holguin at 30-Apr-11 14:19pm
   
my 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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;
}
  Permalink  
v3
Comments
Albert Holguin at 30-Apr-11 14:19pm
   
Hard to interpret what the OP wants, but this may be it... my 5 :)
Hans Dietrich at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 539
1 Maciej Los 300
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 30 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100