Thread: HELP with strlen and strcmpi

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    17

    Exclamation HELP with strlen and strcmpi

    Hello all,

    I was wondering if anyone can tell me what alternatives I have to using these two functions the strlen, and the strcmpi?

    I'm trying to write this code and I was wondering could I use string.length instead of strlen and how would I be able to do this:

    Code:
    l=strlen(word);
    and then how am I able to change these two functions:

    Code:
    if (!strcmpi (word2,word)) {cout<<"\n\t\t\t      "<<strupr(word)<<"\n\n\t\t\tCongratulations\n"; break;}
    to use some other method of writing this piece of code, but to evaluate to the same output? Meaning the strcmpi, and the strupr

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    I'm trying to write this code and I was wondering could I use string.length instead of strlen
    strlen is used on strings that are null terminated char arrays, which are referred to as c-style strings. The length() function is a function of the <string> class, and it's used on string types, which are sometimes referred to as c++ strings. So, if the string you are trying to determine the length of is a null terminated char array, then you use strlen(), but if the string is a string type, then you use the length() function.

    the strcmpi, and the strupr
    Never heard of them.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    the Netherlands
    Posts
    5

Popular pages Recent additions subscribe to a feed