NeroReflex

Simula cin e cout

May 10th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. #ifdef _MSC_VER
  4. std::fstream cin, cout;
  5.  
  6. void apri() {
  7.     cin = std::fstream("input.txt");
  8.     cout = std::fstream("output.txt");
  9.  
  10.    if ((!cin) || (!cout)) {
  11.        printf("Non ho copiato i file!");
  12.        exit(0);
  13.    }
  14. }
  15.  
  16. void chiudi() {
  17.    cin.close();
  18.    cout.close();
  19. }
  20. #endif
  21.  
  22. #ifndef _MSC_VER
  23. using namespace std;
  24. #endif
  25.  
  26. int main() {
  27.    #ifdef _MSC_VER
  28.    apri();
  29.    #endif  
  30.  
  31.    //usa tranquillamente cin e cout
  32.  
  33.    #ifdef _MSC_VER
  34.    chiudi();
  35.    #endif
  36.  
  37.    return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment