Search code examples
cvisual-studio-debugging

Inconsistency between the debugger and running the program


I have a pretty large program (that's why I won't show code), that has a quit() function that prints all errors and prints an exit message, no matter what happens in the program, it will reach the quit() function. Problem is, when I run the program, sometimes it reaches said quit() method and prints the exit method, and sometimes it doesn't, it ends without printing the exit message. I don't get why this happens, and what's more weird is that when I debug the program, it always works. I read that the debugger has certain features which allow for less crashes.

Can you tell me where comes the inconsistency and what should I do to fix it.

Note: My program is written in C, and I'm compiling with Visual Studio 2013 (C++).

Thanks.

SOLVED: The problem was that I access unallocated memory (I dynamically allocated, but not enough). Solution in my case was to realloc().


Solution

  • I think I figured out what was wrong, fileNames is allocated 2 places for char *, when I allocate more place then I give it names, then it works, I just need to realloc.