mardi 6 novembre 2018

Sending text file name from command line c++

I want to run my code and send my file in 2 ways 1. myprogram > input.txt 2. myprogram input.txt

I have figured out the secong way using argc and argv[] but I am not able to figure out how to write the code for the first option.

int main (int argc, char *argv[])
{
     ifstream fin;
     if(argc > 1){

        fin.open (argv[1]);
     }
     else
}

Aucun commentaire:

Enregistrer un commentaire