![]() |
VOOZH | about |
In C, we may need to read the input entered by the user that includes the paragraph of text with spaces. In this article, we will learn how to read a paragraph of text with spaces in C.
In C, reading a paragraph of text that includes spaces can be done by using , This function reads a line from the specified stream and stores it into the string pointed to by str. It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is reached, whichever comes first.
The below program demonstrates how we can use the fgets function to read a paragraph of text with Spaces:
Output
Enter a paragraph of text:
Hello Geeks
This is a tutorial on Reading a Paragraph of Text with Spaces in C
Paragraph you entered:
Hello Geeks
This is a tutorial on Reading a Paragraph of Text with Spaces in C
Time Complexity: O(N), where N is the total number of characters in the paragraph.
Auxiliary Space: O(N)
Note: We can also use to read multiple paragraphs or continue reading until a specific condition is met.