[DGD] sscanf

Erwin Harte harte at xs4all.nl
Wed Dec 5 04:51:31 CET 2001


On Tue, Dec 04, 2001 at 07:36:22PM -0800, Chooser Fireman wrote:
> Question on sscanf ... how can I do:
> 
> if (sscanf(sInput, "%s %s", sParam1, sParam2)
> 
> and allow for sParam2 to be more than 1 word and even a sentence?

That's the default behaviour of DGD, as opposed to the C *scanf()
behaviour:

    void
    process_input(string line)
    {
        string verb, rest;

        if (sscanf(line, "%s %s", verb, rest) < 2) {
            verb = line;
            rest = nil;
        }
        /* ... */
    }

This will split up a line like 'put foo in bar' into 'put' and
'foo and bar' or a line like 'smile' into 'smile' and nil.

Erwin.
-- 
Erwin Harte <harte at xs4all.nl>
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list