When I use the lines:
char *sentence = (char *)malloc(100);
scanf("%[^\n]%*c",sentence);
to read a line from stdin into the buffer, sentence, but then have:
printf("%s\n", sentence);
afterwards, I notice that printf prints the entire sentence as opposed to just the first word from the line. Why is this? Shouldn't printf take only up to the first white space? If not, how does it know where to stop? Sentence surely doesn't end in a "\n" since it doesn't read the last return, and we used *c to read one character and not store it.