Bonjour � tous,

nouveau en C++ j'aimerais me servir d'une id�e de la FAQ pour rediriger l'entr�e/sortie standard 'cin'/'cout'. J'ai donc repris ce qui se trouve dans la FAQ ( http://cpp.developpez.com/faq/cpp/?p...SL_redirection) pour d�finir � partir de la console les fichiers entr�e/sortie. J'obtiens alors une erreur � la compilation que je ne comprends pas.

Voil� pour le bout de code incrimin�, avec pour exemple le m�me code que dans la FAQ pour la sortie 'cout':

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
int CommandShell::startShell(int argc, char* argv[]){	
// Reading the options
int fileopt;
int EOO = -1;
while((fileopt = getopt(argc, argv, "i:o:")) != EOO) {
	switch(fileopt) {
	case 'i':
		// the commands are read from a defined file
		// redirecting the std input
		break;
	case 'o':
		// the commands are written into a defined file
		// redirecting the std output
	        std::ofstream Out("Toto.txt");
	        std::streambuf* OldBuf = std::cout.rdbuf(Out.rdbuf());
		break;
	default:
		usage(argv[0]);
		break;
	}
}
}
et l'erreur incrimin�e:
Citation Envoy� par g++
..\CommandShell.cpp: In member function 'int libforefire::CommandShell::startShell(int, char**)':
..\CommandShell.cpp:48: error: jump to case label
..\CommandShell.cpp:43: error: crosses initialization of 'std::streambuf* OldBuf'
..\CommandShell.cpp:42: error: crosses initialization of 'std::ofstream Out'
..\CommandShell.cpp:43: warning: unused variable 'OldBuf'
Build error occurred, build is stopped
Merci pour votre aide !!