#include <iostream>
int main() {
int favorite_number;
std::cout << "Enter your favorite number between 1 and 100:";
std:cin >> favorite_number;
std::cout << "Amazing!! That's my favorite number too!" << std::endl;
return 0;
}
This is my code, for some reason once I try to run it it automatically exits and it doesn't ask me an input. Even if I put stdio.h, nothig happens
Does anyone know a solution to this?
CodePudding user response:
I try to compile your code but there is an error on the cin line. Try to put two colons before the cin clauses.
NOT
std:cin >> favorite_number;
BUT
std::cin >> favorite_number;
Bye and having a good day
CodePudding user response:
It seems that you are missing a ":" before "cin" in the following line:
std:cin >> favorite_number;
It should be:
std::cin >> favorite_number;
CodePudding user response:
"std:cin >> favorite_number;"
In the above line of code a ':' is missing before 'cin'.
Rewrite it as below
#include <iostream>
int main() {
int favorite_number;
std::cout << "Enter your favorite number between 1 and 100:";
std::cin >> favorite_number;
std::cout << "Amazing!! That's my favorite number too!" << std::endl;
return 0;
}