Thread: Programming using strings

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    3

    Post Programming using strings

    Hi I'm sorry I new to this, and I've been trying to program this all day, I don't know what I'm doing, I can't get my out put or run to work, please help me out on just this problem, I sware I won't bother anyone with hw again



    The main program will
    read in one string which consists of two words Ex. "Computer Science"
    call a function makewords() which receives three parameters: a string which holds the original phrase and two strings to hold the two words. The function will break the string stored in the first parameter (the original sentence) into two words and then store it in one of the parameters.
    Note: The function can assume there is exactly one space between the words in the sentence.
    For example, if the original sentence holds: "computer science", then the two words are "computer" and "science”.
    You should use member functions such as find and substr to help you with this function
    Your function, makewords(), should then check if the 2 new strings are equal to each other, and print the appropriate message saying whether or not they are equal.
    print out the two words and their sizes.
    call the function matchexact() passing the two strings. matchexact() will determine how many times the corresponding positions in the two strings hold exactly the same characters. The function will print this value.
    For example, if the two strings are "marriage" and "gerbil", then the function matchexact will return 2, since the two strings have the same characters in positions 2 and 5.
    If the two strings are "starts" and "tarts", then the function will return 0, since the two strings never have the same characters in the same positions.
    The main program will then call a function jointhem() which receives the two strings. The function will join the two strings together and print the new string. Ex. if string1 is “bath” and string2 is “water” than the new string is “bathwater”
    Run the program a couple of times showing me different examples.

  2. #2
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    No, we won't do your homework for you. Show some effort.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  3. #3
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Word of advice: "use std::string". Read the tutorials in this web for further readings.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    3
    I guess you want to see my program, mautd....I told you I've been trying with my Complier, I don't want to be embarrased, I don't know what I'm doing, but thanx I guess for your comment....

    and g4j31a5 thanx for the hint, but that still leaves me blank....

    sorry i guess

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Understand that no one will code this for you.
    Understand also that no one feels sorry for the fact you didn't pay attention in class.

    When you get that and show us some code, we will gladly help you fix any mistakes and even throw in the explanation for those mistakes and how to avoid them in the future as a bonus.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    3
    whatever....

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. Problem with Strings, Please help!
    By varus in forum C++ Programming
    Replies: 8
    Last Post: 11-27-2006, 11:47 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