I would to use sscanf()
or (preferably) fscanf()
to scan /proc/meminfo
and return MemTotal
:
MemTotal: 1027156 kB
MemFree: 774596 kB
Buffers: 23816 kB
Cached: 198300 kB
Since the number of spaces between MemTotal:
and the actual number varies, I'm wondering if sscanf()
is smart enough to parse something like:
sscanf($line, "MemTotal:\s+%d");
Will the padding and alignment specifiers of sprintf()
work with sscanf()
as well?
I would try this out on my own, but I don't have a dev / Linux environment available ATM.