I have to prepare a function that delivers the average CPU load for a certain period with C++ in vxWorks. With

# include
taskDelay (sysClkRateGet()*20); // Wait 20 s
spyReportCommon((FUNCPTR) printf);

I get the load printed. To return the load, I think I have to call spyReportCommon with my own written function as a parameter. This function has to scan the spy output and write it into variables which can be returned afterwards.

I.e. is this the right way?
How could the scanning function look like?