[LIBC] Modfied Version of sscanf
Martin Möller
moeller.akt at googlemail.com
Sun May 1 14:45:22 UTC 2011
Am 01.05.11 00:53 schrieb "Daniel O'Connor" unter <doconnor at gsoft.com.au>:
Thanks for your reply.
Ok, another example. I try to parse a request, coming from a client in the
form:
GET <resource> HTTP/1.1.
It is expected that <resource> can contain space characters (even if
its not the case in reality).
How would you do that with sscanf ?
With regards,
Martin
>
> 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