Code Competitions

Coding competition

Monday, 13 May 2013

Program to write and read integer values.

#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fpd;
    int i;
    clrscr();
    fpd=fopen("Data.txt","w");
    scanf("%d",&i);
    while(i!=-1)
    {
        putw(i,fpd);
        scanf("%d",&i);
    }
    fclose(fpd);

    fpd=fopen("Data.txt","r");
    printf("\n\n");
    while((i=getw(fpd))!=EOF)
    {
        printf("%d\t",i);
    }
    fclose(fpd);
    getch();
}

No comments:

Post a Comment