Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 18th, 2012  |  syntax: None  |  size: 0.45 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. streambuf* cout_sbuf = cout.rdbuf(); // save original sbuf
  2.     ofstream fout("ScapeLog.txt");
  3.     cout.rdbuf(fout.rdbuf()); // redirect 'cout' to a 'fout'
  4.     cout << "Sortie console C++" << endl;
  5.    
  6.     //extern "C" { //Je sais pas pourquoi ça marche que sans le extern
  7.         FILE *fp;
  8.        
  9.                 if((fp=freopen("ScapeOut.txt", "w" ,stdout))==NULL) {
  10.                         printf("Cannot open file.\n");
  11.                         exit(1);
  12.                 }
  13.                
  14.                 printf("Sortie Console C.\n");
  15.         //}