Thread: strings

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    15

    strings

    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:

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

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    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
    Location
    Chappell Hill, Texas
    Posts
    2,332
    A regular expression would be the least amount of code to write.
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    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