file_size()

file_size()#

file_size() returns the size of a file in bytes, given its path.

Prototype

off_t file_size(const char *path);

Parameters

Key

Type

Description

path

const char *

Path to the file whose size is to be determined.


Return Value

Returns the file size in bytes on success. Returns 0 if the file does not exist or an error occurs.

Notes

This function uses stat() to retrieve file information. If stat() fails, the function returns 0.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples