Thread: creating a string in a buffer

  1. #1

    creating a string in a buffer

    I am having problems again.

    I have a char array buffer that is 50 elements long. It is initialized so all elems are Null \0. I also have a 2D array of strings that are defined. I have to randomly select one column in each row in the matrix to determine which string to put into the buffer. it's like this:

    static char *source [ROWS][COLS] =
    { {"A", "The", "one"},
    {" red", " polka-dot", " yellow"},
    so it randomly generates a sentence. Should I use strcpy or strcat to get these strings into buffer? especially when I don't know what each one's size is? How??

  2. #2
    Registered User
    Join Date
    Sep 2001
    First use strcpy on the first string, then use strcat on the rest.
    // Gliptic

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. How do I make a string buffer?
    By pliang in forum C++ Programming
    Replies: 6
    Last Post: 04-11-2005, 07:19 AM
  5. string handling
    By lessrain in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 07:36 PM