I can declare an integer variable in the program anywhere except for the main
function....I just put:
and it crashes everytime. I can declare globally and in classes with no problem
of crashing. The program lets me declare other variables like strings and bools
though?? Has anyone ever run into this and is it maybe a memory issue or
Alright thanks. One of the programmers here told me to use Valgrind so will check it out. Is it any chance that I can get it working on Windows 7 though because I am told it can only be used on Linux and Mac
I've always wondered the difference between the two. Could you possibly shed some
light on it. Thanks
No the problem is not solved. I tried your program and it compiled but it did not run. I don't
know why but if I run an SDL program then try to run a regular c++ program behind it....
the c++ program never runs. Only when I initially run a regular c++ program does it run
Also, I can declare integer variables globally but the moment I declare them in the main
function or return them from a function to main, the program still crashes. I've have just been using bool variables instead of ints to do the job. I don't know if this means anything but I have around 50 ints declared....maybe that's too many???
And I always get a compiler warning from CodeBlocks saying "process terminated with
My mistake. Can still return ints to main....just had a little mishap with a function. The integer
declaration problem still persists though. I wish I could tell you where it is happening. All I know is the
exact moment I declare an int...crash with a status 3. I've searched and programmers have said that it
maybe loose variables lying around that haven't been initialized so I am checking my program.
There is no need to show all your code. Show the error message. It is obvious that the problem is somewhere else in the code and you could resolve it yourself if would start coding from a simple example.
Hello again everybody. I know I have beaten this horse long enough but after taking everyone's advice and debugging my program [I did not know CodeBlocks had a debugger], I have found the problem. It is this:
message = TTF_RenderText_Solid( font, z , textColor ); .....phew
z [second parameter] being declared as char* z messed up my program and changed addresses to things it wasn't supposed to?? The second parameter is meant to be a number and it is supposed to be decremented every time a condition occurs [when the user presses enter] I did not know how to decrement a number that isn't an integer so I was told to use itoa and atoi functions and they worked but I was digging myself in a hole.
The second parameter in the above function has to be a pointer to a character but I learned I can declare z as a string and just put "z.c_str()" in the second parameter and everything is alright and c++ recognizes z.c_str() as a pointer to a char. Here is my question...I tried using itoa/atoi functions with a string but I got an error so is there any way to convert a string to a number and decrement the number and change it back to a string?