I want to take in persons name using string object. But in my code if I put two part name separated with a space, only first part is displayed. My und ...
I want to take in persons name using string object. But in my code if I put two part name separated with a space, only first part is displayed. My und ...
I'm trying to assign a string to a struct value, which works, but the value somehow links to the variable: The output is: Can someone please exp ...
I came across a curious behaviour (and I am sure it is just curious to me and there exists a perfectly valid c++ answer) when playing around with c-st ...
I have a function string_to_char() which attempts to give me a form of a string which I can pass into a library I am using, which wants char * (but I ...
I am encrypting a message using RSA. Everything works fine if I try to encrypt/decrypt the message locally, however, when converting the string to vo ...
I came across some code which has several instances of the bellow example: In this simplified example there is an assignment of std::string::c_str( ...
This code is working fine for me but every place else I see this code instead I wonder which one is correct and why? ...
Firstly the code listed as follow. run it, and result as follow. (Linux gcc ) cs = 123456 cs = 123456 So, I don't know why the cs pointer is vali ...
Consider this MCVE: I am trying to write a convenience function to reduce the amount of C&P code when inserting similar options into an options ...
For some reason, whether I try strchr or strrchr, I get the same value returned. I have no idea why. Here is the segment of code giving me trouble: ...
I have a const char pointer which I know for sure came from a string. For example: In my case I know myCstring came from a string, but I no longer ...
I am writing a client program and server program. On the server program, in order to write the result back to the client, I have to convert the string ...
I got this problem from a friend My first observation is that the riddle() function will not produce garbage when the number of words passed into i ...
I used VS2010 to build a MFC program in windows 7. I want to format the float data in the report generated. I have tried to use %f but the "%f" is s ...
I need to work with binary files in a program and I've seen reinterpret_cast used, as well as c_str(). Here is a code snippet using c_str(): Here ...
After C++11, I thought of c_str() and data() equivalently. C++17 introduces an overload for the latter, that returns a non-constant pointer (referenc ...
Hi I have a big problem: We created a program in C++/Qt 4.8.4 /Qt Creator 2.8.1 years ago that while executing runs another executable (written and co ...
MyClass.h MyClass.cpp Main.cpp I was expecting program to output Text_5, instead it outputs: ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠ ...
I have this code block as written with strstream. And I converted it to sstream as below. I'm not sure, but I think printStream->str() is returning ...
In the C++ reference of c_str() in std::string the following appears: Return value Pointer to the underlying character storage. data()[i] == opera ...