Answer to Question #214255 in C for Subi

Question #214255

Develop a C program for File Operations that stores n number of the Alphabets from A to Z in a file and display it.


1
Expert's answer
2021-07-06T07:22:25-0400
#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]);
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS