Sign in
Log inSign up

What's the role of EOF used in getw() function in C file programming?

Aritra Mukherjee's photo
Aritra Mukherjee
·Oct 13, 2016

Why cant I print upto 1000 in the program below?

#include <stdio.h>
#include <conio.h>
int main()
{
    FILE *fp;
    int n,i;
        fp=fopen("aritraa.txt","w");
        for(i=0;i<1000;i++)
    {
        putw(i,fp);
    }
    fclose(fp);    
    printf("Displaying the numbers............\n");
    fp=fopen("aritraa.txt","r");
    while((n=getw(fp))!=EOF)
    {
    printf("%d\t",n);
    }
    fclose(fp);
    return 0;
    }