Final Answer:
The reason scanf() isn't ideal for reading strings in C is primarily because it doesn't handle string terminators well (option b). This function stops reading input when encountering whitespace, making it unsuitable for reading strings with spaces or multiple words.Thus correct option is c) It causes buffer overflow
Step-by-step explanation:
The scanf() function in C is designed to parse input based on specific format specifiers. When used to read strings, it stops reading characters once it encounters whitespace, treating it as the end of input. This limitation makes it unsuitable for reading strings that contain spaces or multiple words since it stops prematurely (as indicated in option b). For instance, if you input "Hello World," scanf() would only read "Hello" before halting at the space.
To handle strings in C effectively, functions like fgets() or gets() are more suitable. They allow reading entire lines of text, including spaces, until a newline character (Enter key) or specified delimiter is encountered. These functions ensure complete string input, allowing the storage of strings with spaces or multiple words without premature termination.
Attempting to use scanf() for string input might lead to unexpected behavior or buffer overflow (as suggested in options a and c), especially when the input size exceeds the allocated buffer space, potentially causing memory corruption or security vulnerabilities due to improper handling of input. Therefore, while scanf() is useful for specific data types, it's not the best choice for reading strings in C programs.Thus correct option is c) It causes buffer overflow