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?