• Advertisement

Archived

This topic is now archived and is closed to further replies.

Put some strings together

This topic is 5614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I put some strings together? ____________________________________________________________ Nothing dosen´t exist. Does it?

Share this post


Link to post
Share on other sites
Advertisement
*sigh* More info please.
  • Do you mean character strings (char*'s)
  • Do you mean std::string?
  • Do you mean "How do i allocate space for strings"?
  • Do you mean "How do i concattonate strings" (i can't spell )
  • Do you mean "How do i make my own string class?




    [edited by - Evil Bill on December 2, 2002 2:20:52 PM]

    Share this post


    Link to post
    Share on other sites

    Line them up side by side - carefully take an end of each string between thumb and forefinger - cross ends over each other and twist. Bring first end under and through loop in second string and pull taught. Voila!

    (also, if you are using STL - WHICH YOU SHOULD BE - use MyString += MyOtherString or MyString = MyFirstString + MySecondString - if you are using C or C++ without STL (spit), use strcat).

    Oh by the way, what language\platform are you using and what exactly are you trying to do?

    Byee

    Share this post


    Link to post
    Share on other sites
    cough

    do you want to know in C, Visual Basic, C++, Java, Ruby?

    in c++ if you''re using std::string you can just add them


      
    #include <iostream>
    #include <string>

    using std::cout;
    using std::string;
    using std::endl;

    string greeting("hälsning");
    string name = "peter";
    string age("16");
    string space(" ");
    string wholeText = greeting + space + name + " who is" + age + " years old";

    cout << wholeText;

    cout << greeting << space << name << " who is " << age << " years old";

    Share this post


    Link to post
    Share on other sites
    quote:
    Original post by Robbo
    Line them up side by side - carefully take an end of each string between thumb and forefinger - cross ends over each other and twist. Bring first end under and through loop in second string and pull taught. Voila!

    you obviously never were a sailor
    strings tied in such a manner would not withstand the high seas!

    Share this post


    Link to post
    Share on other sites
    I want to put some chars together, without STL.

    ____________________________________________________________
    Nothing dosen´t exist. Does it?

    Share this post


    Link to post
    Share on other sites

        
    char a[50];
    char b[50];
    strcpy(a,"Hello ");
    strcpy(b,"World!");
    strcat(a,b);





    [edited by - Evil Bill on December 2, 2002 2:51:18 PM]

    Share this post


    Link to post
    Share on other sites
    quote:
    Original post by petewood
    any reason for not wanting to use std::string?


    Yeah, I don´t know STL yet and it works fine with standard C++.



    ____________________________________________________________
    Nothing dosen´t exist. Does it?

    Share this post


    Link to post
    Share on other sites
    quote:
    Original post by peter86
    Yeah, I don´t know STL yet

    Then now is a good time to start. std::string is easier to use than char arrays.
    quote:

    and it works fine with standard C++.

    So does std::string.

    Share this post


    Link to post
    Share on other sites

    This topic is 5614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

    If you intended to correct an error in the post then please contact us.

    Guest
    This topic is now closed to further replies.

    • Advertisement