smashingpumpkin smashingpumpkin - 1 year ago 91
C Question

Command line argument like user input in c++

In command line argument like

./a.out echo *
will be changed by the terminal so that all the files in the directory can be printed. What I want is that standard input do the same thing.

Is there any way of doing this in C++? Any help will be thanked.

Answer Source

Please have a look at

you could write:

int main(int argc, char** argv)
  for(int i=0; i<argc; i++)
    printf("Element %d : '%s'\n", i, argv[i]);

  return 0;

Note: If you want to do this steps in C please have a look here Simple glob in C++ on unix system?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download