See below in comment.
int main(){
//freopen("input.txt","r",stdin);//if I uncomment this line the console will appear and disappear immediately
int x;
cin>>x;
cout<<x<<endl;
system("pause");
return 0;
}
How to make it work?
Solution 1: use
cin.ignore
instead ofsystem
:Solution 2: if you are using MS Visual Studio, press Ctrl+F5
Solution 3: reopen
con
(will only work on Windows, seems your case)If you use solution 3, don't forget to add comments on what the code is doing and why :)