-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I am communicating with a server who needs null terminated string
How can I do this smartly in C#?
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've come across odd behavior when comparing strings. First assert passes, but I don't think it should.. Second assert fails, as expected...
[Fact]
public void StringTest()
{
string testString_1 = "My name is Erl. I am a program\0";
string testString_2 = "My name is Erl. I am a program";
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I'm using boost::program_options and it suffers from the same as many other c++ libs, even std itself: It still uses C-style null-terminated strings, because nobody really likes the weak std::string.
The method in question is:
options_description_easy_init&
operator()(const char* name,
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Is this code correct?
char *argv[] = { "foo", "bar", NULL };
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
If the array was null-terminated this would be pretty straight forward:
unsigned char u_array[4] = { 'a', 's', 'd', '\0' };
std::string str = reinterpret_cast<char*>(u_array);
std::cout << "-> " << str << std::endl;
However, I wonder what is the most appropriate way to…
>>> More