EmbLogic's Blog

fgets – scanning string with spaces

Prototype : -

#include <stdio.h>

char *fgets(char *s, int size, FILE *stream);

Defination :-

fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s.  Reading  stops  after an EOF or a newline.  If a newline is read, it is stored into the buffer.  A terminating null byte (”) is stored after the last charac?
ter in the buffer.
Use :-

It is used to scan a string with spaces until a new line character or EOF character is inserted.

It takes input until enter is pressed.

It is used in place of scanf();

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>