Skip to content

Instantly share code, notes, and snippets.

@rahman541
Created January 29, 2016 12:48
Show Gist options
  • Save rahman541/fe9e7fd52767ab7c329d to your computer and use it in GitHub Desktop.
Save rahman541/fe9e7fd52767ab7c329d to your computer and use it in GitHub Desktop.
C++ File I/O Operation
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream Finput;
Finput.open ("file.txt");
char str[100];
cout<<"Enter String : ";
cin.getline(str,sizeof(str));
Finput << str;
Finput.close();
std::ifstream infile("file.txt");
std::string line;
while (std::getline(infile, line)){
std::istringstream iss(line);
int a, b;
if (!(iss >> a >> b)) { break; }
}
cout<<line;
//system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment