I am reading the data from a file and I need to extract only integers from the below data.How do I accomplish it? Thanks.
My input will be field6 and I need to remove these characters “];” and store it in an integer variable.
My code:-
field6 = strtok(NULL," ");
if (isdigit(field6))
{
weight = atoi (field6);
printf("%d\n",weight);
}
Input:
43];
2];
4];
16];
25];
Output:
43
2
4
16
25
Without sscanf then: