nerdexam
National_Instruments

200-500 · Question #147

You want to extract the pieces of a date string, which looks like this: "2005-11-02". Which of the following pieces of code will properly assign $year, $month and $day with their respective values?

The correct answer is A. sscanf("2005-11-02", '%d-%d-%d', $year, $month, $day). See the full explanation below for the reasoning.

Question

You want to extract the pieces of a date string, which looks like this:

"2005-11-02". Which of the following pieces of code will properly assign $year, $month and $day with their respective values?

Options

  • Asscanf("2005-11-02", '%d-%d-%d', $year, $month, $day);
  • Bscan("2005-11-02", '%d-%d-%d', $year, $month, $day);
  • Csscanf('%d-%d-%d', "2005-11-02", $year, $month, $day);
  • Dsscan($year, $month, $date '%d-%d-%d', "2005-11-02");

How the community answered

(23 responses)
  • A
    78% (18)
  • B
    13% (3)
  • C
    4% (1)
  • D
    4% (1)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice