[DGD] sscanf direction

Felix A. Croes felix at dworkin.nl
Mon Jan 12 21:39:58 CET 2004


"Robert Forshaw" <iouswuoibev at hotmail.com> wrote:

> I have a question about sscanf (and yes I did check the archives, I don't 
> think the answer was there...), which I think is to do with the direction in 
> which the pattern is processed. For instance, if I wanted to strip the 
> filename from the end of a pathname string, would I do this?:

Here's how you answer any one-line LPC code question:

Start DGD with the kernel library.
Login as admin.
Type:

    code p = "/some/path/file.c"; sscanf(p, "%s/%*s", p); return p;

If the argument to 'code' does not end in a semicolon, it's assumed
to be an expression and you don't have to return anything.

    code sscanf("/some/path/file.c", "%*s/%*s")

Variables a, b, ... z are predeclared with type mixed.  Any code
with a semicolon in it is a statement or series of statements, and
should end in the return of a value, followed by a last semicolon.
You can declare further variables of your own, if you like.

sscanf() is useful, but also take a look at explode().

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list