"%s" is the default parsing format of a string in scanf(). "%s" does not include blanks or tabs etc. Here we need an end of sentence character like full stop or $ or new line (\n) to tell scanf() that we are at the end of an input. Some compiler also supports "%[...]" to scan blanks and tabs in the string. Let us see an example where user types in a sentence and gives full stop at the end.

Example Code:
int main(int argc, char *argv[])
  char string[20];
  printf("Enter the sentence, end with full stop or dot \n: ");
  scanf("%[^.]", string);

About our authors: Team EQA

You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.