Solved programming problem

Scan Value From A Text File and Print it in

Source code

#include <stdio.h>

int main()

{

    int n;

    FILE *ptr; ///FILE type pointer

    ptr=fopen("input.txt","r");  ///read the value

    fscanf(ptr,"%d",&n);

    fclose(ptr);   ///close the file

    printf("Scan Value From the Text file is: %d",n);

    return 0;

}

Output

1st Step:

Create an text file and Save value like this

2nd step run the program

Scan Value From the Text file is:13

Join the discussion

Add your comment