Skip to content

Instantly share code, notes, and snippets.

@skymarionsky
Last active March 30, 2019 15:15
Show Gist options
  • Select an option

  • Save skymarionsky/11131028 to your computer and use it in GitHub Desktop.

Select an option

Save skymarionsky/11131028 to your computer and use it in GitHub Desktop.
read file and do something line by line with c++
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream file(argv[1]); // pass file name as argment
string linebuffer;
while (file && getline(file, linebuffer)){
if (linebuffer.length() == 0)continue;
// do something
}
return 0;
}
@ayaheshmat
Copy link

1
2
3
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment