Reading files and initialise file

 #include<stdio.h>


int main(){

    FILE *ptr;

    int num;

    int num2;

    ptr = fopen("sunil.txt", "r");//for reading file

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

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

    fclose(ptr);

    printf("The value of num is %d\n", num);

    printf("The value of num2 is %d\n", num2);

    return 0;

}

Comments

Popular posts from this blog

Snake game.c

Type declaration

Array with function