Has any one know how to read a particular section from the ELF header

i want to scan a c(a.out compiled with gcc -g) executable. that is i want to scan a particular section like (.debug_info) etc it tried the following code but it is not working
it is retuning NULL
eventhough there is a section if u read the executable using readelf --debug-dump

printf ("\n NULL \n");