Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

C Program to find size of a File

#include <stdio.h>
int findfileSize(char f_n[]) {
	FILE* fp = fopen(f_n, "r");
	if (fp == NULL) {
		printf("File Not Found!\n");
		return -1;
	}
	fseek(fp, 0L, SEEK_END);
	int res = ftell(fp);
	fclose(fp);
	return res;
}
int main() {
	char f_n[] = { "b.txt" };
	int result = findfileSize(f_n);
	if (result != -1)
		printf("Size of the file is %ld bytes \n", result);
	return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.