Thread: string concat

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    5

    string concat

    how can i add a string to the end of a char array that contains the string "/bin/" if i have another char array in variable b how do i add it to this other char array containging "/bin/"
    Last edited by weedus; 03-07-2002 at 12:50 AM.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    5
    i still do not understand how to add a char array to an already existing char array

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Well, if you looked at the link, and still can't see how to use strcat() to do what you want, perhaps you're not asking the right question.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    Code:
    #include <string.h>
    #include <stdio.h>
    
    int main (void)
    {
       char string_one[50] = "can you please ",
              string_two[8] ="help me";
    
       /* string two is appended to string one */
       /* make sure string one has enough elements for
           both strings  */
       strcat(string_one, string_two);
       printf(string_one);
       printf("\n%s", string_two);
       return 0;
    }
    this will print
    can you please help me
    help me
    Last edited by bigtamscot; 03-07-2002 at 07:00 AM.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    5
    thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please check my C++
    By csonx_p in forum C++ Programming
    Replies: 263
    Last Post: 07-24-2008, 09:20 AM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM