# contains "stdlib.h"
# contains "string.h"
int main()
{
char * string = " 192. 168. 10.5 ";
char tmp[4][4]= { 0 };
int co[4]= { 0 };
int I = 0;
char *p,* q;
P = q = string;
And (p! = empty)
{
p=strchr(q,'.');
If (p! = empty)
{
strncpy(tmp[i],q,p-q);
q = p+ 1;
i++;
}
}
strncpy(tmp[3],q,string+strlen(string)-q);
for(I = 0; I<4; i++)
{
co[I]= atoi(tmp[I]);
If (me! =3)
printf("%d . ",co[I]);
other
printf("%d\n ",co[I]);
}
}
The extracted integers are stored in int array co.
co[0]= 192
co[ 1]= 168
co[2]= 10
Carbon monoxide [3]=5