Thread: Quick Help Neeeded

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

    Quick Help Neeeded

    can someone please help me I was told by my tutor to remove this piece of code from my program:

    Code:
    char word[50];
    char word1[25];
    He also specified that I use a C++ function rather than the

    Code:
    length=strlen(word);
    and the code

    Code:
    (!strcmpi (word, word1))

    Code:
    strupr(word)
    And i'm really confused, can someone tell me how i can change these to using alternatives to these, as an example the length=strlen(word) to being word.substr????? im not sure? I am not sure what she meant, and I'm reallllllllllyyy confused. I need some help please help i would appreciate your help dearly.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    He probably meant for you to use the C++ std::string
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    85
    Maybe she is telling you to use c++ style strings defined in the <string> header

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

    k, so you mean...

    I should get rid of like she said, then for the fin.getline, I can use:

    Code:
    getline(fin, word)
    ?Thanks for the help by the way

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You can use
    Code:
    string word;
    word.length();
    instead of
    Code:
    char word[N];
    strlen(word);
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM