I have the below code only a part of it is shown here and I am checking if a the type of file.

struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device

"); break; case S_IFCHR: printf(" character device

"); break; case S_IFDIR: printf(" directory

"); break; case S_IFIFO: printf(" FIFO/pipe

"); break; case S_IFLNK: printf(" symlink

"); break; case S_IFREG: printf(" regular file

"); break; case S_IFSOCK: printf(" socket

"); break; default: printf(" unknown?

"); break; }

The problem: value of st_mode obtained when I do a printf("

Mode: %d

",buf.st_mode); the result is 33188.

I tested my program with a regular file type and a symbolic link. In both cases the output was "regular file" i.e the symbolic link case is failing and I fail to understand why?