unknown
2007-05-05 20:16:21 UTC
Hola gente, a ver quien me puede dar una mano con este código de ejemplo:
Tengo el siguiente código:
(sacado de acá http://www.cppreference.com/cppio/constructors.html)
#include <fstream
// #include <iostream>
int main(){
ifstream fin( "/tmp/data.txt" );
ofstream fout( "/tmp/results.txt", ios::app );
while( fin >> temp )
fout << temp + 2 << endl;
fin.close();
fout.close();
return 0;
}
Probe de compilarlo con estos g++ en estas distros:
g++ (GCC) 4.1.1 (Gentoo 4.1.1-r3)
g++-3.4 (GCC) 3.4.6 (Debian 3.4.6-5)
g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Los errores son más o menos estos, en las 3 distros con 3 versiones
distintas del g++:
$ g++ -o prueba prueba.cpp
prueba.cpp: In function 'int main()':
prueba.cpp:6: error: 'ifstream' was not declared in this scope
prueba.cpp:6: error: expected `;' before 'fin'
prueba.cpp:7: error: 'ofstream' was not declared in this scope
prueba.cpp:7: error: expected `;' before 'fout'
prueba.cpp:8: error: 'fin' was not declared in this scope
prueba.cpp:8: error: 'temp' was not declared in this scope
prueba.cpp:9: error: 'fout' was not declared in this scope
prueba.cpp:9: error: 'endl' was not declared in this scope
prueba.cpp:10: error: 'fin' was not declared in this scope
prueba.cpp:11: error: 'fout' was not declared in this scope
Alguna sugerencia???
Porque es que no encuentra la lib del fstream???
Me fijé varias veces y no falta ninguna otra...estoy medio desorientado...
Gracias gente,
Dami y Cele (haciendo tp).
Tengo el siguiente código:
(sacado de acá http://www.cppreference.com/cppio/constructors.html)
#include <fstream
// #include <iostream>
int main(){
ifstream fin( "/tmp/data.txt" );
ofstream fout( "/tmp/results.txt", ios::app );
while( fin >> temp )
fout << temp + 2 << endl;
fin.close();
fout.close();
return 0;
}
Probe de compilarlo con estos g++ en estas distros:
g++ (GCC) 4.1.1 (Gentoo 4.1.1-r3)
g++-3.4 (GCC) 3.4.6 (Debian 3.4.6-5)
g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Los errores son más o menos estos, en las 3 distros con 3 versiones
distintas del g++:
$ g++ -o prueba prueba.cpp
prueba.cpp: In function 'int main()':
prueba.cpp:6: error: 'ifstream' was not declared in this scope
prueba.cpp:6: error: expected `;' before 'fin'
prueba.cpp:7: error: 'ofstream' was not declared in this scope
prueba.cpp:7: error: expected `;' before 'fout'
prueba.cpp:8: error: 'fin' was not declared in this scope
prueba.cpp:8: error: 'temp' was not declared in this scope
prueba.cpp:9: error: 'fout' was not declared in this scope
prueba.cpp:9: error: 'endl' was not declared in this scope
prueba.cpp:10: error: 'fin' was not declared in this scope
prueba.cpp:11: error: 'fout' was not declared in this scope
Alguna sugerencia???
Porque es que no encuentra la lib del fstream???
Me fijé varias veces y no falta ninguna otra...estoy medio desorientado...
Gracias gente,
Dami y Cele (haciendo tp).