by Dinesh Thakur Category: C Programming (Pratical)

In this program user ask to print out the char of a file along with their positions. As user declare the variables for containing the value in it. Here user pointer type variable declaring then ask to enter the file name. if condition will checks out the has file exist or not if the file not exist the message will be file cant open if it exist the while condition will checks out all the character to EOF. With the method of display all the characters will be counted as output.

Problem Statement:

This is C program to count the character in a file.

  1. Declare the variables.
  2. Using control statements.
  3. Display output as result.

Here is C source code counting the character in a file. The output of this program shown below. 

void main()
      FILE *fp;
      char ch,fname[20];
      int n;
      printf("Enter file Name :");
              printf("file can't be opened");
                           printf("%c ",ch);
                           printf("%d \n",n);

Char of a File along with their Positions

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.