Top controls your terminal by using some special terminal characters , thats
for bold the text and highlights it like that ,

If you want to take the process details which has been showned by the top
U better go for ps command ( probably u may use inside the C code too) ,

use the option
Code:
for example 
ps -eo "%p %y %x %c"

since 
 CODE   NORMAL   HEADER
       %C     pcpu     %CPU
       %G     group    GROUP
       %P     ppid     PPID
       %U     user     USER
       %a     args     COMMAND
       %c     comm     COMMAND
       %g     rgroup   RGROUP
       %n     nice     NI
       %p     pid      PID
       %r     pgid     PGID
       %t     etime    ELAPSED
       %u     ruser    RUSER
       %x     time     TIME
       %y     tty      TTY
       %z     vsz      VSZ
For more information refer
Code:
man ps