If I input test and press [esc], the output is he result is "test" for some reason. The T gets removed from the beginning. But if I reach the limit of 20 characters, The result is "..." is displayed normally. The really weird part is, that when using certain characters before of the uppercase T, it is displayed, but when using others it remains the same (he result is "...").
The code is as follows:
#include "stdio.h"
#include "conio.h"
int main()
{
printf("conio.h _getche test\n\n");
char text[21], c;
int n = 0;
printf("Please enter your text: ");
while (1)
{
if (n == 20)
{
text[n] = 0;
break;
}
c = _getche();
if (c == 27)
{
text[n] = 0;
break;
}
text[n] = c;
n = n + 1;
}
printf("\n\nThe result is \"%s\"\n", text);
return 0;
}
I'm really struggling to comprehend what is going on... All help is welcome, thanks in advance.