memmem function

Discussion in 'C Programming' started by LK, Nov 6, 2004.

  1. LK

    LK Guest

    I would like to know what does the following code in c-language do

    int memmem(void *m1, int size1, void *m2, int size2)

    ??
     
    LK, Nov 6, 2004
    #1
    1. Advertising

  2. LK

    Michael Mair Guest

    LK wrote:

    > I would like to know what does the following code in c-language do
    >
    > int memmem(void *m1, int size1, void *m2, int size2)
    >
    > ??


    Well, this code will make your compiler vomit.

    In order to make it a function prototype, add a semicolon after
    the closing ).
    In order to make it a function definition, add { return 0; }
    after the closing ).

    If you want to know whether there is a memmem() function in
    the C standard library, then the answer is no.

    Everything else is offtopic here.

    <OT>
    STFW: Just look at the first result google throws
    you when searching for memmem...
    Basically, this function does the same as strstr but
    for not nearer specified data.
    </OT>

    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Nov 6, 2004
    #2
    1. Advertising

  3. LK

    Flash Gordon Guest

    On 6 Nov 2004 04:55:48 -0800
    (LK) wrote:

    > I would like to know what does the following code in c-language do
    >
    > int memmem(void *m1, int size1, void *m2, int size2)
    >
    > ??


    If you add a semicolon to the end of the line it provides a prototype
    for a function called memmem. If you add a function definition after the
    line then it defines a function. Without either of those it causes the C
    compiler to produce a diagnostic.

    The C standard does not provide a function called memmem, but GNU
    provides it as an extension but the prototype is different. So I suggest
    that you ask on a group or mailing list dedicated to whatever system you
    are using.
    --
    Flash Gordon
    Sometimes I think shooting would be far too good for some people.
    Although my email address says spam, it is real and I read it.
     
    Flash Gordon, Nov 6, 2004
    #3
  4. LK

    Dan Pop Guest

    In <-gordon.me.uk> Flash Gordon <> writes:

    >On 6 Nov 2004 04:55:48 -0800
    > (LK) wrote:
    >
    >> I would like to know what does the following code in c-language do
    >>
    >> int memmem(void *m1, int size1, void *m2, int size2)
    >>
    >> ??

    >
    >If you add a semicolon to the end of the line it provides a prototype
    >for a function called memmem. If you add a function definition after the
    >line then it defines a function.


    It also invokes undefined behaviour, by defining a reserved identifier.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
    Currently looking for a job in the European Union
     
    Dan Pop, Nov 9, 2004
    #4
    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. James Vanns
    Replies:
    7
    Views:
    7,080
    Evan Carew
    Jan 21, 2004
  2. komal
    Replies:
    6
    Views:
    1,443
    msalters
    Jan 25, 2005
  3. Replies:
    2
    Views:
    944
    Bengt Richter
    Aug 1, 2005
  4. Giannis Papadopoulos

    Function pointer to void function and int function

    Giannis Papadopoulos, Sep 5, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,261
    Barry Schwarz
    Sep 5, 2005
  5. barcaroller

    memmem()

    barcaroller, May 8, 2011, in forum: C Programming
    Replies:
    16
    Views:
    2,201
    Nobody
    May 10, 2011
Loading...

Share This Page