C fgets ( )


This function reads a line of characters from the respective line and it gets the string from the group.

Syntax:

char * fgets(char *s, int n, FILE *stream)

Example:

#include <stdio.h>
#include <stdlib.h> 

void main(){  
    FILE *fp;  
    char st[30];  
    fp=fopen("file.txt","r");  
    printf("%s",fgets(st,30,fp));  
    fclose(fp);  
} 



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.