String concatination

This is a discussion on String concatination within the C++ Programming forums, part of the General Programming Boards category; Hi freind I have a doudt here is my code Code: void endtag(string& label) { string temp2; string str1; string ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    4

    String concatination

    Hi freind I have a doudt

    here is my code
    Code:
    void endtag(string& label)
    {
    	string temp2;
    	string str1;
    	string str2;
    	str1= "\" ;
            str2=readlabel(temp);
    	if(str2!= (str1+label))
    	{
    		cout<< " end tag is wrong "<<endl;
    	}
    }
    I am not able to add (' \' to label )=like this "\book" assume the label here is book .can I do this....

    help me please.......

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    yes, assuming that your string is an std::string

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    The \ is a special character you need to "escape" by putting another \ in front of it like \n (newline), \t (tab), etc... So, it should be "\\" and not "\".
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 10:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21