Reading a file using fscanf() || File handling || C programming
In this program, we are going to read to a file using fscanf() with the help of C Programming Language.

 


#include <stdio.h>

void main()
{

    FILE *fptr;
    int rollno;
    char name[20];
    float marks;

    fptr = fopen("sample.txt", "r");
    fscanf(fptr, "%d %s %f", &rollno, name, &marks);

    printf("Roll No.: %d", rollno);
    printf("Name = %s", name);
    printf("Marks = %.2f", marks);

    fclose(fptr);
}

//.....coded by ANANYA MAURYA

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post