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

Discussion

Even if integer/float arguments are supplied at command prompt they are treated as strings.

  • A.True
  • B.False

Answer: A

Correct answer: True

The shell passes arguments as text, and argv is an array of char *, so a program invoked as prog 42 receives the two-character string "42" and not the number 42.

Converting is the program's own job, with atoi, strtol or sscanf. Forgetting it produces the error the companion question shows, where adding two char * values is rejected outright - and, more insidiously, arithmetic on the character codes where the compiler happens to allow it.

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

Post your comment

Please log in or register to post a comment.