Hi.
I'm new in the forum.
I was testing Xcode, and others IDE like eclipse, in my new Mac with the following c++ code:
The question that this piece of code does not work as do in Windows-Visual C++ environment. In particular the cin.get(c) inside the do construction does not allow me to enter a character in the keyboard in the second time and the programs goes into a loop.
I'm compilig this code with gcc compiler.
I'm sure is a well known issue in the Mac comunity so thanks in advance for who give me some indications.
I'm new in the forum.
I was testing Xcode, and others IDE like eclipse, in my new Mac with the following c++ code:
Code:
#include <iostream>
using namespace std;
int main (){
char c;
do {
cout << "Press a key" << endl;
cin.get(c);
cin.sync();
cout << "Key pressed : " << c << endl;
}while (c != '\n');
cout << "Press any key to continue...";
cin.sync();
cin.get();
return 0;
}
The question that this piece of code does not work as do in Windows-Visual C++ environment. In particular the cin.get(c) inside the do construction does not allow me to enter a character in the keyboard in the second time and the programs goes into a loop.
I'm compilig this code with gcc compiler.
I'm sure is a well known issue in the Mac comunity so thanks in advance for who give me some indications.
Last edited by a moderator: