Develop a C program for File Operations that stores n number of the Alphabets from A to Z in a file and display it.
#include <stdio.h>
//Develop a C program for File Operations that stores n number of the Alphabets from A to Z in a file and display it.
main(void)
{
FILE *fpt;
int n,i,j;
char Alpha[26];
fpt = fopen("./Alphabats.txt","w");
for(n=0;n<26;n++) fprintf(fpt,"%c\n",'A'+n);
fclose(fpt);
fpt = fopen("./Alphabats.txt","r");
for(n=0;n<26;n++) fscanf(fpt,"%c\n",&Alpha[n]);
fclose(fpt);
i=0; j=0;
while(i<=0 || i>26) {printf("\nEnter the starting number (1 to 26): "); scanf("%d",&i);}
while(j<=i || j>26) {printf("\nEnter the ending number (%d to 26): ",i+1); scanf("%d",&j);}
printf("\nCharacters as retrieved from file from n = %d to %d:\t",i,j);
for(n=i;n<=j;n++) printf("%c, ",Alpha[n]);
}
Comments
Leave a comment