Re: back to basics



In some cases you might find it easier to use either
g_shell_parse_argv () or g_shell_parse_argv () as alternatives to
scanf() when using glib. Numbers may then be extracted through a
simple atof() or atoi().  This usually gives better control and error
handling than scanf(), imo.

Note though, that if you are using scanf, this means that you are
parsing a syntax. You'd be better off choosing one of the common meta
syntaxes for expressing your data. E.g. XML, JSON, YAML. (Though the
latter appearantly has no c-binding), or "ini" files through the
GKeyFile parser() in glib.

Regards,
Dov

On 9/23/06, Anna <christiana hipointcoffee com> wrote:
On Fri, Sep 22, 2006 at 09:05:42PM +0100, Yiannis wrote:
> Hi, a very basic question but I ve been looking in all the api to find the
> answer.... Are there any equivalent functions in glib for scanf and sscanf and
> where please? Thx.

I believe the idea with GLib providing replacements for standard libc
functions is to fix bugs and make them work the same on all supported
platforms, whenever possible.  Presumably, if the originals are bug free
and already work the same on all platforms then there is no reason to
create a replacement/wrapper, so there wouldn't be one.  Maybe this is
the case with scanf.

- Anna

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]