100% C prog to create a file and (i) Print back full content and (ii) then to print only Capital letters from file
/*ధన్యవాదములు to student who asked genuine doubt and made the teacher think*/
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
fptr=fopen("nayA_1601.txt","w");
printf("\n start entering the data: \n ");
ch=getchar();
while(ch!='z')
{
fputc(ch,fptr);
ch=getchar();
}
fclose(fptr);
printf("\n writing is over. lets read now:\n");
fptr=fopen("nayA_1601.txt","r");
printf("\n\n start reading the data from the file: \n ");
while(!feof(fptr))
{
ch=fgetc(fptr);
putchar(ch);
}
fclose(fptr);
printf("\n\n lets now read only those which are in capital letters:\n");
fptr=fopen("nayA_1601.txt","r");
printf("\n start reading the data from the file: \n ");
while(!feof(fptr))
{
ch=fgetc(fptr);
if((ch>=65 &&ch<=92))
putchar(ch);
}
fclose(fptr);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
fptr=fopen("nayA_1601.txt","w");
printf("\n start entering the data: \n ");
ch=getchar();
while(ch!='z')
{
fputc(ch,fptr);
ch=getchar();
}
fclose(fptr);
printf("\n writing is over. lets read now:\n");
fptr=fopen("nayA_1601.txt","r");
printf("\n\n start reading the data from the file: \n ");
while(!feof(fptr))
{
ch=fgetc(fptr);
putchar(ch);
}
fclose(fptr);
printf("\n\n lets now read only those which are in capital letters:\n");
fptr=fopen("nayA_1601.txt","r");
printf("\n start reading the data from the file: \n ");
while(!feof(fptr))
{
ch=fgetc(fptr);
if((ch>=65 &&ch<=92))
putchar(ch);
}
fclose(fptr);
getch();
}
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.