Hi, Can anyone help me out in guiding me on how to extract this MAC address from the following string. I dunno how to get ride of this space in sscanf format specifier expression. The regular expression don't seems to fetch things properly.
Any guidance would me much appreciated.
char str = "eth0 Link encap:Ethernet HWaddr 00:80:66:10:C0:4D inet addr:22.214.171.124 Bcast:126.96.36.199 Mask:255.255.255.0";
if( sscanf( str, "%*s HWaddr %s %*s", output) == 1)
Thanks a lot
EDIT: The only problem which I tent to have is ti ignore the spaces. For example after eth0 you have got quite a lot of spaces. How would you eliminate those spaces. I tried
So that I can ignore the spaces.
while ( sscanf(ptr, "%[^ ]%n", field, &n) == 1 )
while ( sscanf(ptr, "%[^ ]+%n", field, &n) == 1 ) Something like that