Ну у меня сначала пишет ряд букв, а потом после окончания целого ряда букв - можно уже писать. Надеюсь понятно объяснил xD
Там же используется функция _getch() которая сразу отлавливает код нажатого символа :)
Вот мой код:
// game3.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <stdio.h>
#include "stdlib.h"
#include "time.h"
#include "Windows.h"
#include "conio.h"
int _tmain(int argc, _TCHAR* argv[])
{
const int lettersCount = 20;
char letters [ lettersCount ];
int shag = 0;
int errors = 0;
// System setup
time_t currentTime;
time (¤tTime);
srand(currentTime);
//Initialization
shag = 0;
for( int i = 0; i < lettersCount; i++)
{
letters[i] = 'a' + rand() % ( ('z' - 'a') +1);
}
system("cls");
printf("\n\tReady?\n");
_getch();
printf("\t");
for( int i = 0; i < 5; ++i)
{
printf(".");
Sleep(175);
printf("\n\tGo!");
Sleep(350);
}
do {
system("cls");
printf("\n\t");
for(int i =0; i<lettersCount; i++)
{
if (i<shag)
{
printf("%c ", 176);
}
else
{
printf("%c ", letters[i]);
}
char inputChar=_getch();
if ( inputChar == letters[shag])
{
shag++;
}
else{
errors++;
}
}
}
while(shag<lettersCount);
system("cls");
printf("\tErrors: %i\n", errors);
printf("\n\tPress any key to continue...");
_getch();
return 0;
}
Вот это блок не должен быть внесен под for:
printf("\n\tGo!");
Sleep(350);
А вот этот соответственно не должен быть внесен под второй for:
char inputChar=_getch();
if ( inputChar == letters[shag])
{
shag++;
}
else{
errors++;
}