memcmp (Groß- und Kleinschreibung berücksichtigen)



  • Hallo,

    kann mir jmd. erklären wie ich bei meiner memcmp Funktionsanwendung auf Klein- und Großschreibung achten kann?

    static unsigned char TEST_PATTERN[] = {"Hallo"}
    
    if(memcmp((void *)pdata, (void *)TEST_PATTERN, (sizeof(TEST_PATTERN)-1))==0)
    {
      //Anweisungen ausführen
    
    }
    

    z.B: möchte ich gern, dass die if-Anweisung ausgeführt wird, wenn pdata "Hallo", "hallo" oder jede andere Form (Groß- und Kleinschreibung) dieses Wortes beinhaltet.

    gruß
    der kleine fritz



  • ^^zeichenweise testen, aber vorher beide zeichen mit tolower() bzw. toupper() gross oder klein machen.
    🙂



  • Gelle Fricky, memicmp() wäre zu einfach ...



  • Scheppertreiber schrieb:

    Gelle Fricky, memicmp() wäre zu einfach ...

    da hab' ich nie von gehört. ist bestimmt aus linux oder wo gibt's die?
    🙂



  • Hab ich hier unterm Schreibtisch ... neben der Bierkiste ... 🙂

    Synopsis:

    #include <string.h>
    int memicmp( const void *s1,
    const void *s2,
    size_t length );
    int _memicmp( const void *s1,
    const void *s2,
    size_t length );
    int _fmemicmp( const void __far *s1,
    const void __far *s2,
    size_t length );

    Description:

    The memicmp function compares, with case insensitivity (upper- and lowercase characters are equivalent), the first length characters of the object pointed to by s1 to the object pointed to by s2.

    The _fmemicmp function is a data model independent form of the memicmp function that accepts far pointer arguments. It is most useful in mixed memory model applications.

    The _memicmp function is identical to memicmp. Use _memicmp for ANSI/ISO naming conventions.

    Returns:

    The memicmp function returns an integer less than, equal to, or greater than zero, indicating that the object pointed to by s1 is less than, equal to, or greater than the object pointed to by s2.

    See Also:

    memchr, memcmp, memcpy, memset

    Example:

    #include <stdio.h>
    #include <string.h>

    void main()
    {
    char buffer[80];

    if( memicmp( buffer, "Hello", 5 ) < 0 ) {
    printf( "Less than\n" );
    }
    }

    Classification:

    WATCOM

    _memicmp conforms to ANSI/ISO naming conventions

    Systems:

    memicmp - All, Netware

    _memicmp - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32
    _fmemicmp - All



  • Scheppertreiber schrieb:

    Hab ich hier unterm Schreibtisch ... neben der Bierkiste ... 🙂

    ok, also ist's ne microsoft-nahe funktion. im c-standard ist sie nicht erwähnt, wie ich glaube.
    🙂



  • nein im c-standard ist sie nicht definiert.... 😞



  • Ich hab sie mir auch selbern geschrieben, bis ich letzthin festgestellt habe, dass VS die doch tatsächlich drin hat.


Anmelden zum Antworten