In C++, what's an easy way to turn:  This std::string  \t\tHELLO WORLD\r\nHELLO\t\nWORLD     \t   Into:  HELLOWORLDHELLOWORLD
37193
What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way?
120219
When I do   str="Hello World\n===========\n"   I get the \n printed out too. How can I have newlines then?
45276
I'd like to create a random string, consisting of alpha-numeric characters. I want to be able to be specify the length of the string.  How do I do this in C++?
108226
I'm trying to write a function that formats every (string) member/variable in an object, for example with a callback function. The variable names are unknown to me, so it must work with objects of all classes.  How can I achieve something similar to array_map or array_walk with objects?
49684
Is there a name for the use of symbols in place of curse words, for example #$@&amp;%*!?
15270
Many C++ books contain example code like this...  std::cout &lt;&lt; "Test line" &lt;&lt; std::endl;   ...so I've always done that too. But I've seen a lot of code from working developers like this instead:  std::cout &lt;&lt; "Test line\n";   Is there a technical reason to prefer one over the other, or is it just a matter of coding style?
82841
This seems like a pretty softball question, but I always have a hard time looking up this function because there seem there are so many variations regarding the referencing of char and tchar.
4602
Example (note the case):  string s = "Hello world!"; String s = "Hello world!";   What are the guidelines for the use of each? And what are the differences?
8878
Does anyone know of any good C++ code that does this?
19961
I have a multi-line string literal that I want to do an operation on each line, like so:  inputString = """Line 1 Line 2 Line 3"""   I want to do something like the following:  for line in inputString:     doStuff()
31820
If I want to construct a std::string with a line like:  std::string my_string("a\0b");   Where i want to have three characters in the resulting string (a, null, b), I only get one.  What is the proper syntax?
78607
I want to make C# look nice in my book, but with the following:  C\# it looks like this:    When it should look more like this:    For the second one, I used verbatim, but I don't want that and I've also used a macro like the following everywhere so it should be easy to replace:  \def\Csharp{C\#}  Any suggestions on how I make this look correct?  Edit  I am writing a programming book, in the C# Language Specification, it looks like this:
23598
What's the most efficient way to concatenate strings?
32361
I have some numbers of different length (like 1, 999, 76492, so on) and I want to convert them all to strings with a common length (for example, if the length is 6, then those strings will be: '000001', '000999', '076492').   In other words, I need to add correct amount of leading zeros to the number.  int n = 999; string str = some_function(n,6); //str = '000999'   Is there a function like this in C++?
1464
introduces  which will allow the introduction of new literal syntax based on existing literals (int, hex, string, float) so that any type will be able to have a literal presentation.  Examples:  // imaginary numbers std::complex&lt;long double&gt; operator "" _i(long double d) // cooked form {      return std::complex&lt;long double&gt;(0, d);  } auto val = 3.14_i; // val = complex&lt;long double&gt;(0, 3.14)  // binary values int operator "" _B(const char*); // raw form int answer = 101010_B; // answer = 42  // std::string std::string operator "" _s(const char* str, size_t /*length*/)  {      return std::string(str);  }  auto hi = "hello"_s + " world"; // + works, "hello"_s is a string not a pointer  // units assert(1_kg == 2.2_lb); // give or take 0.00462262 pounds   At first glance this looks very cool but I'm wondering how applicable it really is, when I tried to think of having the suffixes _AD and _BC create dates I found that it's problematic due to operator order. 1974/01/06_AD would first evaluate 1974/01 (as plain ints) and only later the 06_AD (to say nothing of August and September having to be written without the 0 for octal reasons). This can be worked around by having the syntax be 1974-1/6_AD so that the operator evaluation order works but it's clunky.   So what my question boils down to is this, do you feel this feature will justify itself? What other literals would you like to define that will make your C++ code more readable?    Updated syntax to fit the final draft on June 2011
100452
CString is quite handy, while std::string is more compatible with STL container. I am using hash_map. However, hash_map does not support CStrings as keys, so I want to convert the CString into a std::string. Writing a CString hash function seems to take a lot of time. CString -----&gt; std::string  How can I do this? std::string -----&gt; CString:  inline CString toCString(std::string const&amp; str) {     return CString(str.c_str());  }  Am I right?  EDIT: Here are more questions: How can I convert from wstring to CString and vice versa? // wstring -&gt; CString std::wstring src; CString result(src.c_str());  // CString -&gt; wstring CString src; std::wstring des(src.GetString());  Is there any problem with this? Additionally, how can I convert from std::wstring to std::string and vice versa?
17204
I'm using VS 2008 to create a C++ DLL (not managed) project and I need convert a char* to a long long type. Is there an easy way to do it?  Thanks in advance :)