Skip to content

Instantly share code, notes, and snippets.

@jesuscmadrigal
Created October 27, 2017 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesuscmadrigal/91e7e9abd05792e03aa4cb12a903f17c to your computer and use it in GitHub Desktop.
Save jesuscmadrigal/91e7e9abd05792e03aa4cb12a903f17c to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct datos
{
int l,c;
};
datos func(string ruta, datos& there)
{
ifstream archivo(ruta.c_str(), ios:: in);
char car;
string theline;
while(getline(archivo, theline))
{
there.l++;
there.c = there.c + theline.length();
}
return there;
}
int main()
{
datos here;
string url;
cout<< "Enter the file URL: "<< endl;
cin>> url;
func(url, here);
cout << "Number of lines: "<< here.l << endl;
cout << "Number of characteres: " << here.c << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment