Q:

How can you get a Linux top like output using C

I am trying to get the CPU usage and details of all the running processes on embedded Linux while a C test is running. Is there a top equivalent in C that I could use ?

A:

I'm not sure what aspect of top confuses you, but just take a look at the source code for top.

A:

Instead of top, you should probably use ps with the right arguments and you can parse the output.
You'll have to call that with a system call or popen from your C code. You cannot get this information strictly inside your C code (at least I don't think you can).

