This is the command line execution :
animals cages.txt
How do I code my C++ program to be able to read in the argument as my text file??
This is the command line execution :
animals cages.txt
How do I code my C++ program to be able to read in the argument as my text file??
Code:#include <fstream> using namespace std; int main ( int argc, char **argv ) { if ( argc > 1 ) { ifstream fin ( argv[1] ); if ( !fin ) { // Probably a bad file name } else { // Use fin } } }
My best code is written with the delete key.
See the FAQ
The first command line parameter is pointed to by argv[1]
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks people.