Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: C++ strings

  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    Indiana (USA)
    Posts
    50
    Thanks
    4
    Thanked 0 Times in 0 Posts

    C++ strings

    This sounds like such a stupid question, I can do this is PHP and VB6, but my teacher never told us how to in C++. Lets say I have a string, that will always be the same and this it is hard coded into the program with quotes around it, and then I have something that will change and I need to append that onto the end to place it in a function call. Can anyone tell me how to do this? I have included the equivelent in PHP below

    PHP Code:
    theFunction("This is part one " $appendthis); 
    Last edited by chiefbutz; 07-10-2007 at 10:07 PM.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    It depends what parameter theFunction takes. Is it using the string class or a char*?

    If it is the former:

    Code:
    string appendthis;
    
    //Your code
    
    theFunction("This is part one" + appendthis);
    OracleGuy


  •  

    Posting Permissions

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