1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Basic string question

Discussion in 'C' started by laserlars, Aug 28, 2010.

  1. laserlars

    laserlars New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi!

    I'm pretty new to C and have to write something that handles strings.
    I have some experience with python and C++ but i find C string handling pretty strange/ugly.

    Is the following code really the best way to put together a string containing multiple strings?

    strcat(string1, string2);
    strcat(string1, string3);
    strcat(string1, string4);
    strcat(string1, string5);

    In python i would do something like:
    string1 = "%s" + string3 + "%s" % (string2, string4)
     

Share This Page