[LIBC] Modfied Version of sscanf

Daniel O'Connor doconnor at gsoft.com.au
Sat Apr 30 22:53:56 UTC 2011


On 01/05/2011, at 2:14, Martin Möller wrote:
> outputs total garbage on my FreeBSD-7.0-RELEASE #0 amd64.
> Is there already a way to do this or should we release a new version of
> sscanf, e.g. called sscanfWS.
> 
> This modified version would output: Test 2->Test 3.

I think it does what it should.. %s is supposed to stop at whitespace.

You probably really want..

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

int
main(int argc, char **argv) {
    char name [20], value [20];
    int i;

    i = sscanf("Test 2->Test 3", "%[^-]->%[^-]", name, value);
    printf("%d %s->%s\n", i, name, value);

    exit(0);
}

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C








More information about the freebsd-hackers mailing list