I was given this exercise:
Imagine, somebody wants to write a letter. Each sentence is entered using a single scanf-command execution. Each sentence is to be stored in a character array of optimal length. If the user enters a line which only consists of a dash (-), the text is assumed to be finished. After all text has been entered, it is to be printed out to the console.
I couldn't quite get what it means but I decided to try and write an email using scanf
#include <stdio.h>
int main()
{
char name1[100];
char mail1[9999];
char name2[100];
printf("Dear ");
scanf("%s", name1);
scanf("%s", mail1);
printf("Sincerely,");
scanf("%s", name2);
return 0;
}
This is what I could write. After I write someone's name after it prints "Dear", I just write the body of the letter but if I write more than one word it doesn't let me write anything after Sincerely
%sformat specifier reads space-delimited words. - Some programmer dudefgets. - Fiddling Bits