Computer Science, asked by TbiaSamishta, 1 year ago

Can we use scanf() to read a strings? If no, then give reason. Why it is wrong to use the & symbol when reading in a string with scanf()?

Answers

Answered by Brainlycurator
2

Yes, we can use scanf() for reading a STRINGS .This function is used to read the characters in sequence till it has whitespaces in the line.  

Basically & symbol is used to assign address to the variables used in the program so that values of the variables can be easily and correctly assigned.

For Example: To read the string of arrays using scanf function,

       scanf(“%s”,&string[0])

The format specifier used for string is “%s”. The & symbol gets the value of the string specified in zeroth array.

Similar questions