Skip to content

Instantly share code, notes, and snippets.

@amrhamedp
Forked from skymarionsky/FileRead.cpp
Created July 29, 2017 05:09
Show Gist options
  • Select an option

  • Save amrhamedp/1b351395ceb3a11cf42d174db192cfb7 to your computer and use it in GitHub Desktop.

Select an option

Save amrhamedp/1b351395ceb3a11cf42d174db192cfb7 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment