c++ a heap has been corrupted error when running the program

I have not reviewed the whole code, but there are tools available that can help you in this situation that track the usage of memory and indicate if something went wrong. One example is valgrind that is at least available for Linux environments. Anyway, this tool allowed me to find at least one bug in … Read more

How do I deal with “signed/unsigned mismatch” warnings (C4018)?

I work with a lot of calculation code written in c++ with high-performance and low memory overhead in mind. It uses STL containers (mostly std::vector) a lot, and iterates over that containers almost in every single function. The iterating code looks like this: But it produces the signed/unsigned mismatch warning (C4018 in Visual Studio). Replacing … Read more

‘cout’ does not name a type

The problem is that the code you have that does the printing is outside of any function. Statements that aren’t declarations in C++ need to be inside a function. For example:

C++ multiline string literal

Well … Sort of. The easiest is to just use the fact that adjacent string literals are concatenated by the compiler: The indentation doesn’t matter, since it’s not inside the quotes. You can also do this, as long as you take care to escape the embedded newline. Failure to do so, like my first answer … Read more

Critical error detected c0000374 – C++ dll returns pointer off allocated memory to C#

If all your code is indeed what is shown above, then I don’t see the problem. However, when I get this issue, sometimes its because malloc/new/whatever detects heap corruption, often this corruption has already occurred previously in the program, but the crash has been delayed until the next call to new/malloc. If you read other … Read more

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