Created
August 21, 2012 01:00
-
-
Save raarce/3410121 to your computer and use it in GitHub Desktop.
Command line argument example 03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Command line argument example #03 | |
#include <iostream> | |
#include <fstream> | |
#include <cassert> | |
using namespace std; | |
int main ( int argc, char *argv[] ) | |
{ | |
string st; | |
fstream filestr; | |
if ( argc < 2 ) { | |
cout<<"usage: "<< argv[0] <<" <filename>\n"; | |
exit(1); | |
} | |
filestr.open(argv[1]); | |
assert(filestr.is_open()); | |
filestr >> st; | |
while(!filestr.eof()) { | |
cout << st << " "; | |
filestr >> st; | |
} | |
filestr.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment