On Sat, 2008-05-17 at 13:31 +0100, Neil Puttock wrote:
> Thanks for your comments, Joe.
> 
> I'm struggling a bit with sscanf () though. I tried your suggestion of
> 
> if (sscanf (s.c_str (), "%d") != s.size ()) ...
> 
> but it fails with a segfault; when compiling, I get two warnings: that
> there's not enough arguments to sscanf (), and about type conversion
> (shouldn't s.size () be cast as int for this comparison?)
> 
> It works OK (ignoring the cast) if I change it to
> 
> if (sscanf (s.c_str (), "%d", &len) != s.size ()) ...
> 
> but I'm a bit confused here: doesn't sscanf () return the number of
> variables which have successfully been assigned values? If so, how can
> the test work?

Sorry, I was under the mistaken impression that sscanf returned the
number of characters that were converted. But given that there's a
scheme function that already does this (should have read the whole
conversation first...) I agree with Nicolas that it's better just to
make that public (or stick a public string->duration function in the
same file as parse-simple-duration).

Joe



_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to