Extract integer from char buffer

c

Solution

Can use sscanf per line, like:

#include <stdio.h>
int time = -1;
char* str = "Timings results : 120012";

int n = sscanf(str, "Timings results : %d", &time);

in this case n == 1 means success

Problem

I have a very simple problem in C. I am reading a file linewise, and store it in a buffer ``` char line[80]; ``` Each line has the following structure: ``` Timings results : 2215543 Timings results : 22155431 Timings results : 221554332 Timings results : 2215543 ``` What I am trying to do, is to extract the integer value from this line. Does C here provide any simple function that allows me to do that? Thanks

Original source

Related problems