#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(void)
{
char ch[100];
FILE *p;
p = fopen("text.txt", "w+");
printf("Enter the text to store in file : ");
gets(ch);
fputs(ch, p);
fclose(p);
// --------------------------------------------------------------
//counting number of character in file
int lenght = 0;
p = fopen("text.txt", "r");
while (!feof(p))
{
fgets(ch, 100, p);
lenght = strlen(ch);
}
printf("Number of Character in file is %d", lenght);
fclose(p);
//----------------------------------------------------------------
}
0 comments:
Post a Comment