Device Major/Minor numbers

To further my fledgling knowledge of C, I am re-writing some of the Unix command set. My current command is an ls-style command.

All works well, except for device files. How do I get the major/minor numbers for the dev files?

I see from the stat struct there are st_rdev and st_dev members. Do these members relate to the major/minor numbers in any way?

I've read through man 2 stat and I can't suss the device file specifics out.

Any help would be greatly appreciated.

Cheers
ZB

Many thanks Driver, that's exactly what I was looking for.

my_ls.c is now coming on very nicely!

Thanks again
ZB