Voici mon code:
voici l'erreur que j'obtiens avec g++ test.cpp:
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 #include<algorithm> #include<cmath> #include<iostream> #include<string> #include<vector> using namespace std; int main (int argc, char* argv[]) { ifstream entree(arg[1]); vector<string>::iterator IterAvant; vector<string>::reverse_iterator IterRecul; vector<string> c1; string recup(""); if ( !entree ) { cerr <<"erreur fichier"; return 0 ; } while ( getline(entree, recup)) { if ( recup =="display"|| recup =="rdisplay") break ; c1.push_back(recup); } cout <<"\r\nPremiere lecture du fichier : "<< endl; cout <<"taille du vector : "<< c1.size()<< endl; if ( recup =="display") { for (IterAvant = c1.begin(); IterAvant != c1.end(); IterAvant++) cout <<*IterAvant << endl; } else if ( recup =="rdisplay") { for (IterRecul = c1.rbegin(); IterRecul != c1.rend(); IterRecul++) cout <<*IterRecul << endl; } else { cout <<"\r\nRien n'a ete lu dans le fichier..."<< endl; } entree.close(); }
$g++ test2.cpp
test2.cpp: In function 'int main(int, char**)':
test2.cpp:12: error: variable 'std::ifstream entree' has initializer but incomplete type
test2.cpp:12: error: 'arg' was not declared in this scope
$
est une fois la compilation terminée je doit trouver ce résultat donc si vous pouviez m'aidez a le terminer ca serai vraiment sympa.
Je tiens vraiment a remercier tout ceux qui m'aide depuis le debut de mon post et qui sont patient.
resultat attendu :
Exemples :
$ cat was_demo1
hello
world
great
$ ./test < was_demo1
hello
world
great
$ cat was_demo2
hello
world
rdisplay
this
is
great
$ ./test < was_demo2
world
hello
this
is
great
$ ./test < /dev/null
$
Partager