C++: Leer de un fichero de texto (1)
Leer una línea de un fichero de texto usando C++
Lenguaje: C++ (compilador: G++ 4.5.2 Linux)
Categoría: Básico
// Fuente procedente de ErrorDeSintaxis.es
// Leer una línea de un fichero de texto usando
// C++
// Compilador: G++ 4.5.2 Linux
// Nivel: Básico
// Disponible desde 29/07/2011
// Aportado por Nacho
// Autor original: Nacho Cabanes
// Web original: http://www.aprendeaprogramar.com/mod/resource/view.php?id=344
#include <iostream> #include <fstream> using namespace std; int main () { ifstream ficheroEntrada; string frase; ficheroEntrada.open ("ficheroTexto.txt"); getline(ficheroEntrada, frase); ficheroEntrada.close(); cout << "Frase leida: " << frase << endl; return 0; }