+ Reply to Thread
Results 1 to 3 of 3

 

Thread: Concatenation

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Feb 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts


    How can i concatenate two strings after getting form user in c++??

  2. #2
    buy.at tech

    Status
    Offline
    Join Date
    Jul 2008
    Posts
    64
    Thanks
    1
    Thanked 11 Times in 11 Posts
    It depends what you're using to store your strings.

    If you're using std::string (i.e. you probably got hold of the strings from iostream) then concatenation is simple through the operators built into std::string, + and +=. e.g.:
    Code:
    using namespace std;
    
    string toasties = "toasties";
    string cheese = "cheese";
    string food = toasties + " " + cheese;
    food += " mmmm";
    cout << food << endl;
    If however you're using plain char* for your string then you'll need to a function, strcat from stdio.h is standard.
    Ian Sproates, Head of Development (Newcastle), buy.at
    tel: +44 (0)191 222 9728 | email: ian.sproates@buy.at | icq: 490-111-853 | msn: sproates@hotmail.com

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Feb 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The Code Is very Effective and efficient Thanks a lot for this.

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2