Skip to content

Instantly share code, notes, and snippets.

@f1729
Created July 1, 2018 11:14
Show Gist options
  • Save f1729/9d97799e581a51d31575f11edcba3bf0 to your computer and use it in GitHub Desktop.
Save f1729/9d97799e581a51d31575f11edcba3bf0 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream> // para ficheros
#include <string.h>
#include <vector>
#include <regex>
using namespace std;
void lectura_datos(){
cout<<"Project: "<<endl;
}
int main() {
std::string line;
int number_of_lines = 0;
lectura_datos();
string nombre_data;
cout<<"\n\n";
cout<<"Ingresar el nombre del archivo:";
ifstream F; // para lectura
F.open("data.txt");
cout<<"\n\n";
if (F.fail()) {
cout<<"No se pudo abrir el archivo";
exit(1);
}
while (std::getline(F, line)) {
if (number_of_lines == 0) {
std::cout<<line<<endl;
} else {
if (!line.find("FB")) {
std::cout<<"\n" + line<<endl;
}
if (!line.find("WINTEM") || !line.find("F450")) {
std::cout<<line<<endl;
}
}
++number_of_lines;
}
std::cout <<"Number of lines in text file: "<< number_of_lines;
F.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment