This code is written in C++ and for reasons that I don\'t quite understand it is written twice. I would expect that after inputting a random char it would display the char once
as everyone already mentioned, cin
will append the newline marker \n
every time you hit enter. another solution is to place cin.ignore();
after every cin.get();
.
#include
using std::cin;
using std::cout;
using std::endl;
int main()
{
char letter;
letter = cin.get();
cin.ignore();
while (letter!= 'X')
{
cout<