Re: *scanf efficiency for patterns

Discussion in 'C Programming' started by Peter Nilsson, Aug 27, 2003.

  1. Christopher Benson-Manica <> wrote in message news:<bigcrr$10o$>...
    > How efficient are the *scanf functions when used for pattern matching?


    The C Standards do not specify levels of efficiency.

    > Specifically, is something like
    >
    > const char * my_str = "Hello, world!";
    > int m;
    >
    > m=sscanf( my_str, "%*[a-zA-Z], %*[a-zA-Z]!" );


    Note that the use of - in the scansets is implementation defined. So
    your request need not match the way you might expect.

    > if( m != 2 ) /* bad string */


    This condition is always true as you do not make any conversion
    assignments.

    > ...
    >
    > faster, slower, or the same as proceeding character by character through the
    > string or stream in question?


    Try it, if you're interested in wasting time on micro-optimisation.
    But the answers are not supportable by the standards, therefore they
    are off topic to clc.

    --
    Peter
    Peter Nilsson, Aug 27, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan Krone

    perl efficiency -- fastest grepping?

    Bryan Krone, Nov 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    1,469
    Jim Gibson
    Nov 8, 2004
  2. crichmon
    Replies:
    4
    Views:
    477
    Mabden
    Jul 7, 2004
  3. Malcolm

    Re: *scanf efficiency for patterns

    Malcolm, Aug 27, 2003, in forum: C Programming
    Replies:
    1
    Views:
    589
    Eric Sosman
    Aug 27, 2003
  4. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    scanf (yes/no) - doesn't work + deprecation errors scanf, fopen etc.

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Feb 16, 2006, in forum: C Programming
    Replies:
    185
    Views:
    3,370
    those who know me have no need of my name
    Apr 3, 2006
  5. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    difference between scanf("%i") and scanf("%d") ??? perhaps bug inVS2005?

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Apr 26, 2006, in forum: C Programming
    Replies:
    18
    Views:
    671
    Richard Bos
    May 2, 2006
Loading...

Share This Page