33279 is the decimal notation of the octal 100777. You get the decimal notation because you requested the number to be printed as decimal using the format identifier %i . %o will print it as an octal number.
However, st_mode will give you much more information. (Therefore, 100 at the beginning.) You will want to use S_IRWXU (rwx information for the user), S_IRWXG (group) and S_IRWXO (other) constants to get permissions for the owner, group and others. They are defined respectively in 700, 070 and 007, all in octal representation. OR, combining them together and filtering out the specified bits using AND, you will only get the data you need.
The last program, thus, becomes something like this:
struct stat buf; stat(filename, &buf); int statchmod = buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); printf("chmod: %o\n", statchmod);
Resources
ilias source share