program for TO COUNT THE NO OF BLANKS IN TEXT FILE USING STANDARD I/O AND SYSTEM CALLS using c-languge


TO COUNT THE NO OF BLANKS IN TEXT FILE USING STANDARD I/O AND SYSTEM CALLS

#include<stdio.h>
#include<conio.h>
void main()
{
char c;
int count=0;
FILE *f1;
f1=fopen("hai.txt","w");
printf("\nEnter text & press ctrl z at the end\n");
while((c=getchar())!=EOF)
{
putc(c,f1);
}
fclose(f1);
f1=fopen("hai.txt","r");
while((c=getc(f1))!=EOF)
{
if(c==' ')
count++;
}
fclose(f1);
printf("\nThe no of blank spaces in the text are %d", count);        }

No comments:

Post a Comment