Difference between ‘strcpy’ and ‘strcpy_s’?

strcpy is a unsafe function. When you try to copy a string using strcpy() to a buffer which is not large enough to contain it, it will cause a buffer overflow. strcpy_s() is a security enhanced version of strcpy(). With strcpy_s you can specify the size of the destination buffer to avoid buffer overflows during copies.

“X does not name a type” error in C++

When the compiler compiles the class User and gets to the MyMessageBox line, MyMessageBox has not yet been defined. The compiler has no idea MyMessageBox exists, so cannot understand the meaning of your class member. You need to make sure MyMessageBox is defined before you use it as a member. This is solved by reversing the definition order. However, you have a cyclic dependency: if you move MyMessageBox above User, … Read more

How to print pthread_t

This will print out a hexadecimal representation of a pthread_t, no matter what that actually is: To just print a small id for a each pthread_t something like this could be used (this time using iostreams): Depending on the platform and the actual representation of pthread_t it might here be necessary to define an operator< for pthread_t, because std::map needs an ordering on the elements:

What is the C version of RMI

Is this type of scenario that CORBA was intended for and if so, is this still the best technology to use or are there better options out there. Yes, this is what CORBA was intended to solve. Whether it’s “best” is subjective and argumentative. 🙂 I can say, from my personal experience, I don’t miss … Read more

What does T&& (double ampersand) mean in C++11?

It declares an rvalue reference (standards proposal doc). Here’s an introduction to rvalue references. Here’s a fantastic in-depth look at rvalue references by one of Microsoft’s standard library developers. CAUTION: the linked article on MSDN (“Rvalue References: C++0x Features in VC10, Part 2”) is a very clear introduction to Rvalue references, but makes statements about Rvalue references that were once … Read more