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

Help! Can someone check this codes?

We need to combine this two codes to create a game in which we have to count how many times we pressed enter for a matter of time. we need to display the instructions above and how many times we hit or pressed the enter button and also the time.

#include
#include
#include
#include
using namespace std;


int main ()
{
while(_kbhit() )
{
int c = getche();
int counter = 0;

if( c == '\n', counter++ )
{
printf("got one\n"); // but instead of this one we need to show the counter
// which we dont know how we can declare it.
}
}
int main ()
{

time_t start,end; // start time and end time

int score=0;
char ans[10];
int ctr;


time (&start); //start timer


printf("GO!");

while(_kbhit() )
{
int c = getche();
if( c == '\n' )
{
printf("got one\n");
}
cout<<"\n";
ctr++;
cout<

cheers07
Newbie Poster
5 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

You are using the variable counter to store how many times the button has been pushed. You can display this value with the printf command:

printf("%i ", counter);
Moschops
Practically a Master Poster
620 posts since Sep 2008
Reputation Points: 258
Solved Threads: 117
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: