Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.cpp
- *
- * Created on: Aug 6, 2011
- * Author: romin
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- //create object of type ifstream and open "data.txt"
- ifstream ifs("data.txt");
- //check to see if "data.txt" was successfully opened
- if(!ifs)
- {
- cerr << "Could not open the file.\n";
- exit(1);
- }
- //read data.txt, a list of integers
- int x=0;
- while(ifs >> x)
- {
- cout << x << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement