Q:

Write a program that accepts the options presented in this section. Print the values of the arguments passed to main

0

Write a program that accepts the options presented in this section. Print the values of the arguments passed to main.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  std::cout << "All " << argc << " argument"
            << (argc > 1 ? "s are:" : " is:") << std::endl;
  for (int i = 0; i < argc; ++i)
    std::cout << i << "\t" << argv[i] << std::endl;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now