[Solved] C#, can’t serialize to binary

I figure out what the error is for those in future who might be banging their head wondering what went wrong. It’s actually really simple. A small typo actually. Too bad M$ have horrible error message that don’t really tell you where the error might have happened: Simply replace this line: public void GetObjectData(SerializationInfo info, … Read more

[Solved] Unexpected output of printf for a string in C

None of those two cases are right. Case 1 only worked because you got lucky, probably by giving a short string as input. Try something like “bfjabfabjkbfjkasjkvasjkvjksbkjafbskjbfakbsjfbjasbfjasbfkjabsjfkbaksbfjasbfkja” and you’ll suffer a seg fault, most likely. You should have a block of memory associated with str, either on the stack by declaring an array for it … Read more

[Solved] How to determine i+++–j in C

Think of it as a greedy algorithm, it will take as many characters as possible, if they make sense. Example: i+ // good, keep going i++ // good, keep going i+++ // not good, start new token + // good, keep going +- // not valid, start new token – // good — // good … Read more

[Solved] Short-Circuit If Condition Does not work

In your example you can have TWO different causes for the NullReferenceException: – Value `user` is null; – `user.FirstName` is null. I assume you’ve checked already if user is not null, so lets skip that one. Now lets assume that user.FirstName is null, what happens then? The first condition string.IsNullOrWhiteSpace(user.FirstName) will result to true. Is … Read more

[Solved] why C style code is faster than C++ style code [closed]

Don’t force a flush: cout << ret[i] << endl; That is really inefficient forcing the stream to flush every time. Rather simply use the \n; cout << ret[i] << `\n’; Also because C++ tried to maintain backward compatibility with C the C++ iostream are linked to the C iostreams. It is expensive to keep them … Read more

[Solved] Function don’t work in the class (c++)

Below is my attempt. There were some formatting issues but the trickiest problem was that getValue() is a const function. class Int { private: int num; public: Int() { num = 0; } Int(int n) { num = n; } // getValue is a const function as it does not alter object ‘n’. int getValue() … Read more