Declare a string variable named course Title. the course Title needs to hold up
ID: 3802820 • Letter: D
Question
Declare a string variable named course Title. the course Title needs to hold up to 50 characters, write a scanf_s to read the course Title from the keyboard and write a print f statement to print the course Title to the screen, left-justified in a field that can hold 50 characters. What happens if the user enters spaces in the name when you are trying to read it in? (From Lab 6) in C there is an alternative to scan for strings. It is called gets (or gets_s). Give an example of how to use it to read in an entire string from the keyboard, including spaces, up to when the user hits .Explanation / Answer
a) Answer: char courseTitle[50];
b) Answer: scanf("%s", &courseTitle);
c) Answer: printf("%s", courseTitle);
d) Answer: if we use to reach a string by scanf an given string is having spaces in between then scanf will read first string up to first space and assigned that value to courseTitle.
e) Answer: If your input string is having space in between then we have to go for the gets() function. gets() function will read the complete line and assign it to string courseTitle.