I can't believe I'm even having to ask this rather simple question but I wouldn't normally use C++ for this, and I'm caught on a snag.
I have some files filled with many entries like this (from unix time command):
real 0m0.475s
user 0m0.091s
sys 0m0.028s
For each line I would like to strip out the minutes and the seconds as an integer and a double respectively, discarding the real/user/sys string, the whitespace, the 'm', and the 's'.
I need to do it in C++...
I have tried to fiddle around with fscanf but with little avail. I would want to write something like...
char rubbish[32]; int mins; double secs;
while (fscanf(pFile, "%s%dm%lfs",rubbish,mins,seconds)!=EOF)
{
...
}
I realise this isn't the correct way of using format specifiers and that I should have a regular expression in there for the m and the s, however it serves for illustration.
Can someone help me out?