 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
giovanni Guest
|
Posted: Sat Jan 15, 2005 10:36 pm Post subject: erreur avec dev c++ |
|
|
me dit erreur :
C:Dev-Cppmain.cpp In function `int main()':
45 C:Dev-Cppmain.cpp `TEXT' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it
appears in.)
45 C:Dev-Cppmain.cpp variable `std::ifstream input' has initializer but
incomplete type
C:Dev-CppMakefile.win [Build Error] [main.o] Error 1
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
void display( int line_num , int v1 , int v2 , int v3 , int v4 ) {
std::cout
<< "# " << line_num << ":t"
<< "v1: " << v1
<< ", v2: " << v2
<< ", v3: " << v3
<< ", v4: " << v4
<< std::endl ;
}
void format_error( int line_num ) {
std::cerr << "Error at line " << line_num << "!n" ;
}
bool is_space( std::string const & s ) {
for ( std::string::const_iterator it = s.begin() ,
end = s.end() ;
it != end ;
++ it ) {
char c = * it ;
if ( ! std::isspace( c ) ) {
return false ;
}
}
return true ;
}
bool is_space( std::istringstream & iss ) {
for ( char c = iss.get() ; iss ; c = iss.get() ) {
if ( ! std::isspace( c ) ) {
return false ;
}
}
return true ;
}
int main() {
const char* nome_del_file = "c:/";
std::ifstream input(TEXT.TXT);
for ( int line_num = 1 ; input ; ++ line_num ) {
std::string line ;
std::getline( input , line ) ;
if ( is_space( line ) ) {
std::cout << "# " << line_num << ":tempty" << std::endl ;
continue ;
}
int v1 = 0 , v2 = 0 , v3 = 0 , v4 = 0 ;
std::istringstream iss( line ) ;
iss >> v1 >> v2 >> v3 >> v4 ;
if ( iss && is_space( iss ) ) {
display( line_num , v1 , v2 , v3 , v4 ) ;
}
else {
format_error( line_num ) ;
break ;
}
}
}
|
|
| Back to top |
|
 |
Gabriel Dos Reis Guest
|
Posted: Sat Jan 15, 2005 11:30 pm Post subject: Re: erreur avec dev c++ |
|
|
"giovanni" <giovannich (AT) hotmail (DOT) com> writes:
| Quote: | me dit erreur :
C:Dev-Cppmain.cpp In function `int main()':
45 C:Dev-Cppmain.cpp `TEXT' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it
appears in.)
45 C:Dev-Cppmain.cpp variable `std::ifstream input' has initializer but
incomplete type
C:Dev-CppMakefile.win [Build Error] [main.o] Error 1
|
Le compilateur a tout dit.
| Quote: | #include <iostream
#include
#include
#include
#include
|
[...]
| Quote: | int main() {
const char* nome_del_file = "c:/";
std::ifstream input(TEXT.TXT);
|
Tu voulais dire
std::ifstream input("TEXT.TXT");
note les guillemets. De plus il te faut
#include
en début de programme.
-- Gaby
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|