Thread: strings

  1. #1
    Registered User
    Join Date
    Oct 2008


    Hello there,

    I am trying to write the algorithm for a program that will return 1 (true) if a string argument ends in the substring OH.

    I'm pretty confused, even though it seems fairly simple.

    Would I accomplish this with an if statement?

    something like:

     if string [i] = 'O' && string [i+1] = 'H'
    return TRUE;
    else return FALSE;

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    RING 0
    Be wary there is no such thing as TRUE and FALSE in C unless you define it yourself. Also your if statement is improperly formed. You should probably look into strstr() and strcmp() for the operation you requested.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    A regular expression would be the least amount of code to write.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  4. #4
    Registered User
    Join Date
    Oct 2008
    you have got it down pat and the next step would be to go from pseudo-code to code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM

Tags for this Thread