Thread: Creating a story with random numbers!

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    44

    Question Creating a story with random numbers!

    Hey guys,
    I'm writing this program which creates a sentence from random words that are part of an array.
    Code:
    Ex.  string Verbs[5] = { "ran", "jumped", "played", "danced", "played"}
    I'm using also nouns, articles, prepositions to create all the parts of the sentence. The problem is when I create a story, I ask the user to input the number of lines they want an story to be.

    Well the first letter of the story should be a capital letter, and the same thing for the rest of the sentences.

    How could I read the fist character of the string and make it a capital letter, and of course I don't want to change the initialization.

    Thank you

  2. #2
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    There is a difference between tedious and difficult.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    44
    ok but if I have a string. how could i just change the first letter
    Code:
    for example:
    
    string brand[1]= {"lexus"};
    
    lexus cars are fast  -> before
    Lexus cars are fast -> after

  4. #4
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    As the link I gave you spells out, toupper() takes a char and returns the upper-case version of it. All you need to do is pass it a char equal to the first letter in your string. Hmmm...how to do that....maybe my friend google knows...
    There is a difference between tedious and difficult.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    In each string, the first letter is str[0]. Use toupper() on it, and it will be capitalized.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. Question about random numbers
    By Kempelen in forum C Programming
    Replies: 2
    Last Post: 07-02-2008, 06:28 AM
  3. Generatin Random Numbers
    By dantu1985 in forum C Programming
    Replies: 15
    Last Post: 08-13-2007, 01:21 AM
  4. Creating Random hex numbers
    By disruptor108 in forum C++ Programming
    Replies: 24
    Last Post: 06-06-2007, 11:00 AM
  5. Creating a UDF to create random numbers
    By rgmills in forum C++ Programming
    Replies: 5
    Last Post: 11-15-2005, 11:22 PM