Leer archivo .txt
Publicado por Luis Eduardo (1 intervención) el 22/03/2019 21:36:26
necesito hacer un programa en c++ que pueda:
a) Leer un archivo .txt
b) Ordenarlo por orden alfabético
c) Preguntar por una búsqueda
d) Imprimir la posición del objeto buscado
Saben como hacerlo, estoy estancado
P.D El archivo .txt contiene 1210 nombres de péliculas.
ESTO ES LO QUE TENGO HASTA AHORA
a) Leer un archivo .txt
b) Ordenarlo por orden alfabético
c) Preguntar por una búsqueda
d) Imprimir la posición del objeto buscado
Saben como hacerlo, estoy estancado
P.D El archivo .txt contiene 1210 nombres de péliculas.
ESTO ES LO QUE TENGO HASTA AHORA
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
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <iterator>
#include <string.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;
int main(){
int nuevo [1210];
int i;
char peliculas[1210][50];
ifstream infile("peliculas.txt");
string line;
vector <string> Nombres;
char nombre[50];
std::string linea;
while(std::getline(infile,line))
{
std::stringstream stream(line);
std::string valor;
std::cout << " ";
while(std::getline(stream,valor,'\n'))
{
Nombres.push_back(line);
}
std::cout <<" ";
}
for (vector<string>::iterator it = Nombres.begin(); it < Nombres.end(); ++it)
cout <<("\n") << *it ;
}
Valora esta pregunta
0