If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday What would be the output? main(int argc, char *argv[]) { while(--argc >0) printf("%s",*++argv); }

A) myprog monday tuesday wednesday thursday
B) monday tuesday wednesday thursday
C) mondaytuesdaywednesdaythursday
D) myprog tuesday thursday

Showing Answers 1 - 5 of 5 Answers

neetu

  • Mar 6th, 2006
 

B, it will print "mondaytuesdaywednesdaythursday"

neetu

  • Mar 6th, 2006
 

sorry, it would be Cmondaytuesdaywednesdaythursday

Yes the correct ans is (C). There will not be any spaces.

Whenever we are entering command line argument and giving sapace between monday & tuesday that to push different pointer to string in agrv. If we will not give any space between monday and tuesday, it will take monday and tuesday as a single string and place the pointer in argv. But at the time of displaying, there is no space defined in printf so that it can print space between two strings.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions