-
-
Save parzibyte/15989c7dab7aab40fc2a5e5d2bd7d97b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<Persona> obtener_personas_de_archivo() | |
{ | |
vector<Persona> personas; | |
Persona persona; | |
ifstream archivo(NOMBRE_ARCHIVO.c_str()); | |
string linea, edad, nombre; | |
while (getline(archivo, linea)) | |
{ | |
stringstream input_stringstream(linea); | |
getline(input_stringstream, edad, DELIMITADOR); | |
getline(input_stringstream, nombre, DELIMITADOR); | |
persona.edad = stoi(edad); // Edad es cadena. Asignamos la propiedad según lo que regrese "stoi" | |
persona.nombre = nombre; | |
personas.push_back(persona); | |
} | |
return personas; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment