Advertisement
cd62131

DirectLineInput

Aug 11th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <string>
  5. using namespace std;
  6. static void direct_line(ifstream& fin, int n, double *x, double *y) {
  7.   string line;
  8.   int c = 0;
  9.   while (getline(fin, line))
  10.     if (++c >= n) break;
  11.   istringstream in(line);
  12.   in >> *x >> *y;
  13. }
  14. int main() {
  15.   double x, y;
  16.   ifstream fin("dat");
  17.   direct_line(fin, 10, &x, &y);
  18.   fin.close();
  19.   cout << x << ' ' << y << endl;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement