Why doesn't it run in Release mode?

I've been working on the Euler project problems, and I have the solution to problem 25, but it only runs in debug mode, if I try to run in release mode then it just hangs there (fin never gets a value). I think the problem is with my addchar() function being used inside of strcpy_s(). Can anyone tell me what's wrong there or if it's a problem somewhere else?

Edit;

Thank you for the help Cire and Ikaron.
I removed the code because Project Euler asks that the solutions to their problems not be posted on other websites, and I was feeling guilty about posting one.
The problem was that I was returning a pointer to a non-static array. Declaring the array as static char num3[3000] = {0}; solved the problem.

I also turned on warnings, I'm not really sure how they got shut off to begin with.

Thanks again.
Last edited on
main.cpp(57): warning C4172: returning address of local variable or temporary


As you're using strcpy_s, I'm pretty sure you're using VC++, in which case you should pay attention to the warnings generated by the compiler, since it tells you exactly what is wrong.

Last edited on
So, yeah, I'm using VC++ 2012, but I'm not getting that warning in either debug or release mode, which is weird.

So I think I understand what you're saying, the local variable is destroyed after the end of my addchar function, so the pointer to it is then pointing to nothing. So should I declare num3 as a static int array? would that change things? I'm now away from my own computer so I can't change it until later tonight, am I on the right track?
So, yeah, I'm using VC++ 2012, but I'm not getting that warning in either debug or release mode, which is weird.


Unless you're at warning level 0 (warnings turned off) then it generates that warning. Now, if your project build is up-to-date and you press the build button, it doesn't actually compile anything. If you want to see which warnings are generated (that warning is one of three) clean first, then build.

Yes, making num3 static would work.
If you want to see which warnings are generated (that warning is one of three) clean first, then build.

You can just use rebuild.
Topic archived. No new replies allowed.