concatenating more than 2 strings

This is a discussion on concatenating more than 2 strings within the C Programming forums, part of the General Programming Boards category; Can you concatenate strings by using an operator, or is strcat the only way. Cuz what if you want to ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    4

    concatenating more than 2 strings

    Can you concatenate strings by using an operator, or is strcat the only way. Cuz what if you want to concatenate more than 2 strings together? I com from a vb background, and we use the + and the & operators. Does C have anything like this?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,852
    > Does C have anything like this?
    No.
    Use strcat() in a loop if you need to do this.

    But C++ strings support the + operator as meaning concatenate.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    thanks for the reply... Ill use a loop.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you can also use sprintf() if you know how many strings need to be concantinated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Easier way of concatenating a lot of strings?
    By Evenstevens in forum C Programming
    Replies: 2
    Last Post: 05-09-2009, 02:29 PM
  2. Concatenating C style Strings Question
    By bengreenwood in forum C++ Programming
    Replies: 3
    Last Post: 03-19-2009, 04:19 PM
  3. concatenating strings?
    By liri in forum C Programming
    Replies: 11
    Last Post: 08-24-2007, 06:34 PM
  4. Concatenating 2 strings
    By AngKar in forum C Programming
    Replies: 14
    Last Post: 04-25-2006, 11:51 AM
  5. Concatenating strings (dynamic array using pointers)
    By Tankndozer in forum C Programming
    Replies: 8
    Last Post: 07-01-2004, 08:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21