elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / getline en: 20 Enero 2019, 16:55 pm
Hola a todos. Llevo unos días aprendiendo a programar y este es el primer problema al que no le veo solución.
En el siguiente programa, el getline hace como si no existiera.Directamente no hace nada. Lo he probado en otro mini-programa y funciona perfectamente, pero en éste no.¿Sabéis qué sucede?

Código:
#include <iostream>
#include <fstream>
using namespace std;

void EscribirEnFichero();
void LeerEnFichero();

int main(){
string PreguntaLeerOEscribir;
Vuelta1:
cout<<"Desea (E)scribir o (L)eer un archivo"<<endl;
cin>> PreguntaLeerOEscribir;
if ((PreguntaLeerOEscribir=="E") || (PreguntaLeerOEscribir=="e")){
EscribirEnFichero();
}
else if ((PreguntaLeerOEscribir=="L") || (PreguntaLeerOEscribir=="l")){
LeerEnFichero();
}
else {
cout<<"No ha escrito una opcion valida.Intentelo otra vez"<<endl;
goto Vuelta1;
}
return 0;
}

void EscribirEnFichero(){
char NombreArchivo[128];
string Texto;
cout<<"Que nombre desea que tenga el archivo"<<endl;
cin>>NombreArchivo;
cout<<"Que desea escribir en el archivo"<<endl;
getline(cin,Texto);                       //Este es el getline que no funciona

ofstream fichero (NombreArchivo);
fichero<<Texto<<endl;
fichero.close();

system("pause()");
}

void LeerEnFichero(){

}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines