fgets in C language

#include <stdio.h>
int main(void)
{
    printf("Please enter a string: ");
    char text[10];
    if (fgets(text, 10, stdin) != NULL)
    {
        printf("You entered: %s\n", text);
    }
    else
    {
        printf("Error in reading input.\n");
    }
    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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