#include <stdio.h>
int main()
{
char filename[100];
char ch;
int count=0;
printf("Enter the filename: ");
scanf("%s", filename);
FILE *file = fopen(filename, "r");
if (file == NULL)
{
printf("Error: Could not open file.\n");
return 1;
}
while ((ch = fgetc(file)) != EOF) {
count++;
}
printf("Number of characters: %d\n", count);
fclose(file);
return 0;
}
Comments
Post a Comment