You want to read the first few lines of /proc/stat. You'll need to read it twice, a measured time apart, and subtract the first set of numbers from the second. The lines look like this:
cpu  1526724 408013 600675 541100340 2861417 528 14531 0 0 0
cpu0 344507 77818 251244 134816146 1119991 324 13283 0 0 0
cpu1 502614 324065 179301 133991407 1631824 136 906 0 0 0
cpu2 299080 3527 79456 136144067 103208 59 255 0 0 0
cpu3 380521 2602 90672 136148719 6393 7 86 0 0 0
intr 2111239193 344878476 16943 ...
The first line is aggregate for all cores. The next lines show each core. When you see the line that start with intr, you know to stop parsing.
Each number is the amount of time the CPU has spent in a particular state. The units are typically hundredths of a second. The fields are user, nice, system, idle, iowait, irq, softirq, steal, guest, and guest_nice.
The authoritative documentation is, of course, the source code. If you have a copy of the Linux kernel source handy, look at fs/proc/stat.c, particularly the show_stat function.