2K8CSE - Generate Index in a FIle - C Program

Program:

// gen.c

#include<stdio.h>

main ()
{

    int i=1;
    FILE *temp;
    temp=fopen("testrecord.txt","w");
    fprintf(temp,"\t2K8CSE\n");
    while(i<39)
    {
        fprintf(temp,"2K86%d\n",i);
        i++;
    }
    fclose(temp);   
}

Output:
nn@linuxmint ~ $ gcc gen.c
nn@linuxmint ~ $ ./a.out
nn@linuxmint ~ $

// testrecord.txt
    2K8CSE
2K861
2K862
2K863
2K864
2K865
2K866
2K867
2K868
2K869
2K8610
2K8611
2K8612
2K8613
2K8614
2K8615
2K8616
2K8617
2K8618
2K8619
2K8620
2K8621
2K8622
2K8623
2K8624
2K8625
2K8626
2K8627
2K8628
2K8629
2K8630
2K8631
2K8632
2K8633
2K8634
2K8635
2K8636
2K8637
2K8638

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...