c++ - expected a; but I already have a ; -


hello trying college homework keep getting error saying expected ; have ; on line. error during cin answer

#include <iostream> #include <string> using namespace std;  int main() { string name; cout << "welcome prison of elders, guardian, name ?."; cin  >> name;  cout << "are ready face challenge" << name <<  "!" << endl; cin answer;    while (1); return 0; 

cin answer;  

should replaced

cin >> answer; 

more generally, "expected thing" compiler message should treated caution. it's guess matches syntax compiler. however, sign of syntax error somewhere. (and not @ line see "expected thing")

to elaborate on why ";" expected : cin identifier, answer

you wrote identifier identifier;, never correct syntax in c++.

the compilator confused seeing 2 identifiers next each other. suggested :

cin; answer; 

which syntactically correct , solve confusion, complete nonsense semantically in code.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -