Programming Languages C Objective
Mar 08, 2013

What will be output of the following c code?

void main()
 {
  char *str;
  scanf("%[^\n]",str);
  printf("%s",str);
}

Choose the correct answer:
A) It will accept a sentence as a string from user
B) It will accept a paragraph as a string from user
C) It will accept a word as a string from user
D) Compiler error
Detailed Explanation

Task of % [^\t] is to take the stream of characters until it doesn’t receive new line character ‘\t’ i.e. enter button of your keyboard.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback