1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

copy one string to another??

Discussion in 'C++' started by umair37, Mar 7, 2012.

  1. umair37

    umair37 New Member

    how to copy one string into another using LOOPS.(i am talking about default string class)??
    the code given below does not work.
    please teach me:)
    void function(string str1)
       string str2;
       int i=0; 
    Last edited by a moderator: Mar 7, 2012
  2. xpi0t0s

    xpi0t0s Mentor

    Your chosen approach is not the correct one. Simply use the assignment operator:
    string str1="Hello";
    string str2=str1;
    Output should be "Hello".

Share This Page