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

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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -