C++ Create file if argc==2? -


i cannot figure out wrong here... want code create file when type 1 argument in terminal. works fine if argc set 1, not above that. appreciated ! cheers & nice sunday

#include <fstream> #include <string> #include <iostream> using namespace std;  int main(int argc, char* argv[]) {     if (argc==(2))     {         ofstream file("myfile.txt"); // creates myfile.txt     }      else     {         cout << "type 1 argument !" << endl;     }     return 0; } 

if using visual studio answer : go project/properties, select "debugging" tab, , enter arguments in "command arguments" field.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -