Machine-translated by Google. Questions are authored in English.
Top

Discussion

In linux, argv[0] by command-line argument can be occupied by _________

  • A../a.out
  • B../test
  • C../fun.out.out
  • D.all of the mentioned

Answer: D

Correct answer: all of the mentioned

argv[0] holds the name by which the program was invoked, and on Linux that is whatever string the user typed to run it - whether ./a.out, ./test or anything else.

The name has no necessary connection to the source file, and a program can be renamed freely. It is not even guaranteed to be a real filename: a shell or an exec call can supply any string it likes, which is what lets a single binary behave differently under several names, as busybox does.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.