Q:

Write a C Program to Find Size of File in File Handling

0

Write a C Program to Find Size of File in File Handling. Here’s simple Program to Find Size of File in File Handling C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Below is the source code for C Program to Find Size of File in File Handling which is successfully compiled and run on Windows System to produce desired output as shown below :

 
 


SOURCE CODE : :

/*  C Program to Find Size of File in File Handling  */

#include <stdio.h>

int main()
{
    FILE *fp;
    char ch;
    int size = 0;
    char * arrr = "C:\\Users\\acer\\Documents\\file4.txt";
    fp = fopen(arrr, "r");
    if (fp == NULL)
        printf("\nFile unable to open ");
    else
        printf("\nFile opened ");
    fseek(fp, 0, 2);    /* file pointer at the end of file */
    size = ftell(fp);   /* take a position of file pointer un size variable */
    printf("The size of given file is : %d\n", size);
    fclose(fp);

    return 0;
}

OUTPUT : :


// The file saved i.e file4.txt is the source code of the program


File opened 

The size of given file is : 576

Above is the source code for C Program to Find Size of File in File Handling which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to Maintain Employee Records using File ... >>
<< C Program to Replace specific Line in File using F...