|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Debug assertion error ?
When i try to execute my .exe it doesnt work after i compile it
all the information can be seen at : http://www.pixelsonmy.tv/help/ there is the error i get (a pic of the screen shot) any ideas on what is wrong? im runnin VSC++ 6.0 on windows XP |
|
#2
|
|||
|
|||
|
Some possibilities:
1) m = new double [rows*columns]; You don't check to see whether m is null or not. Maybe your new request didn't return a valid address? 2)void matrix::set_val(int r, int c, double d){ m[rows * columns + columns] = d; } Your array index goes out of bounds in your loop, and even though that's not illegal, so your program will compile, maybe that's causing a memory problem when you run your program. Last edited by 7stud : February 25th, 2003 at 11:26 PM. |
|
#3
|
||||
|
||||
|
Couple of things I saw right away were --
In main.cpp Code:
matrix M1(3,3); matrix M2(3,3); for (int i = 0; i < 9; i++) M1.set_val(i, i, 2); You're setting M1 to a 3x3 matrix. However, in the for loop right afterwards, you're overrunning a buffer. Your for loop variable goes from 0..8 and you're attempting to access stuff like M1(8,8) when your matrix's max is M1(2,2). Also in matrix.cpp, you have: Code:
void matrix::set_val(int r, int c, double d){
m[rows * columns + columns] = d;
}
I think you really meant this to be: Code:
void matrix::set_val(int r, int c, double d){
m[r * columns + c] = d;
}
BTW your code for operator /= is incorrect as well. There's a logic error in that function, that I trust you'll have no problems finding. Hope this helps! ![]() |
|
#4
|
|||
|
|||
|
Quote:
thank you, i fixed the problem with number 2, im not longer getting that debug anymore, now it just crashes :-\ |
|
#5
|
||||
|
||||
|
>> im not longer getting that debug anymore, now it just crashes :-\
Probably cuz your for loop in main.cpp goes from 0..8. Try changing it to: for (int i=0; i < 3; i++) Also note the other errors I found in your code, in my prev. post on this thread ![]() |
|
#6
|
|||
|
|||
|
maskzilla,
Can you tell me how you did that screen capture? At work, I used to be able to do screen captures of some information in an app, and then save it to look at the next day, but I can't seem to figure out how to do that on my pc at home. |
|
#7
|
|||
|
|||
|
Quote:
Ctrl + Alt +Print Screen, then i just Choose New in Adobe Photoshop, and pasted, i think you can paste in Word too tho |
|
#8
|
|||
|
|||
|
hmm okay, i fixed what i think was the problem, now it runs.. just doesnt do anything :-\ i re-uploaded the fixed pages
|
|
#9
|
|||
|
|||
|
"Ctrl + Alt +Print Screen"
Nothing happens. I tried it on the devshed forum screen. Do I have to have my cursor somewhere special? |
|
#10
|
|||
|
|||
|
Ahhhah! Print Scrn(I didn't have to press Ctrl + Alt + Print Scrn just Print Scrn) may appear to do nothing but it sends the contents of the active window to your clipboard which I was then able to paste into Word. Thanks.
|
|
#11
|
|||
|
|||
|
anyone? :-[
|
|
#12
|
||||
|
||||
|
Dude, you still didn't fix the bugs in your operator /= function yet -- check it carefully and you'll see what the problem is. Also you need to reset your matrix M1 after you declare it (and before calling set_val), so that you know you have 0 for the rest of the elements.
Code:
matrix M1(3,3); M1.reset(); // Set all the elements to 0 initially to be safe for (int i=0; i < 3; i++) // <-- you've got this going one less BTW .... How do I know that this will work. Because I FIXED them last night on my end and got your code to work perfectly. |
|
#13
|
||||
|
||||
|
7stud -- I believe the command is Alt-PrtScrn. PrtScrn by itself captures the entire desktop to the clipboard. Alt-PrtScrn captures only the active window to the clipboard.
|
|
#14
|
|||
|
|||
|
Quote:
duuuuuuuuuuh thank you.. im an idiot |
|
#15
|
|||
|
|||
|
You only tell your program to output "finished" to the screen:
void main(){ matrix M1(3,3); matrix M2(3,3); for (int i = 0; i < 2; i++) M1.set_val(i, i, 2); M1 /= .03; cout << "finished" << endl; } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Debug assertion error ? |
| Thread Tools | Search this Thread |