#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std;
int main() {
FILE* fd;
fd = freopen("1.txt", "w", stdin);
int a = 1;
cin >> a;
cout << a;
fclose(fd);
cin >> a;
cout << a;
return 0;
}
I use freopen to connect stdin and 1.txt. Then, i want to close 1.txt and later work with regular stdin, but is isn't works. What i have to do? (In 1.txt only one number - 1, program at the end puts in console - 11; i want it to put 1, then ask me for a number)