What is stored in the str, if each of the following values, separately, is read in using a single call to scanf()? char str[10]; a) cityscape b) New Delhi c) one or more blanks
Answers
""scanf() function is used to input values in C programming language. While performing string input, it's important to remember that while taking input of a string value (i.e., a text value enclosed in double quotes).
scanf() function inputs the value up to the occurrence of a blank space in the string or in other words, it will just input the first word from the given input text.
So, taking this into consideration, the values read into the array str for giver inputs will be:
a) cityscape
""""cityscape""""
Since it's within the maximum limit of string, the entire value will be taken as input since there is no space between them.
b) New Delhi
""""New""""
Since scanf() function inputs the value only up to the first blank space.
c) One or more blanks
"""" """"
It input the null string since first itself the blank space is identified.