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.

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

Convert float to std::string in C++

Unless you’re worried about performance, use string streams: If you’re okay with Boost, lexical_cast<> is a convenient alternative: Efficient alternatives are e.g. FastFormat or simply the C-style functions.

Class name does not name a type in C++

The preprocessor inserts the contents of the files A.h and B.h exactly where the include statement occurs (this is really just copy/paste). When the compiler then parses A.cpp, it finds the declaration of class A before it knows about class B. This causes the error you see. There are two ways to solve this: Include B.h in A.h. It is generally a good idea to include header files … Read more

Windows 7 exception code: 0xc0000409

I have a C++ windows application that was done by another programmer, that I had to remove one line of code. After rebuilding the application with visual studio 2013 it crashes with this in the event log: The application uses QT 4.7.4, and compiles with no errors. I am an embedded systems programmer and have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)