Monday, December 21, 2009

sscanf with expression

Using expression with sscanf

int main()
{
char rangestr = "10.32.125.224 - 220.12.32.52";
char ip1[16], ip2[16];
retval = sscanf(rangestr, "%[^'-'] - %s", ip1,ip2);
printf ("return calue = %d ip1 = %s, ip2 = %s",retval,ip1,ip2);

return 0;
}

%[^'-'] = From '^' start read till '-' character

No comments:

Post a Comment