Tuesday, July 14, 2009

What's the standard functions for string process in C++?

I'm learning C++ programming. In my textbook, I only find some function for string processing such as "strcmp" or "strcat". But they are more widely used in old C. I want to know some newer function for string in C++, which process strings as "objects"?


If you know, tell me in detail (examples are best), Plz! Thanx.

What's the standard functions for string process in C++?
See: http://cplusplus.com/reference/string/st...





The page above describes what a string object is in C++ and gives details on its member functions and avaliable operations.








For example, assume:





std::string a = "Test"


std::string b = "Example"





Then, strcmp and strcat in C++ with string objects would be:





if ( a == b ) a+= b;





That is, if a is the same as B ( value wise ) then make a's value the sum of the value of a and b ("TestExample")


No comments:

Post a Comment