C ++ redirection

Often you need to redirect the input and output when the test code, the following is a simple example.

    freopen ("input.txt", "r", stdin);
    int n;
    cin>>n;
    cout<<"n is "<<n<<endl;

Guess you like

Origin www.cnblogs.com/yeran/p/10959633.html