I am just wondering how to go about emulating zcat -d command through c?

normally I would do something like

Code:
zcat -d filename | grep something
but I wanted to do this through c programming and wondering if there is anyway internally to do it through c ?