The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Debug assertion error ?
Discuss Debug assertion error ? in the C Programming forum on Dev Shed. Debug assertion error ? C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 25th, 2003, 10:19 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
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
|

February 25th, 2003, 11:16 PM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|

February 25th, 2003, 11:30 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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! 
|

February 25th, 2003, 11:32 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: Originally posted by 7stud
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. |
thank you, i fixed the problem with number 2, im not longer getting that debug anymore, now it just crashes :-\
|

February 25th, 2003, 11:35 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
>> 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 
|

February 26th, 2003, 12:11 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|

February 26th, 2003, 12:52 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: Originally posted by 7stud
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. |
Ctrl + Alt +Print Screen, then i just Choose New in Adobe Photoshop, and pasted, i think you can paste in Word too tho
|

February 26th, 2003, 01:01 AM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
hmm okay, i fixed what i think was the problem, now it runs.. just doesnt do anything :-\ i re-uploaded the fixed pages
|

February 26th, 2003, 03:20 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
"Ctrl + Alt +Print Screen"
Nothing happens. I tried it on the devshed forum screen. Do I have to have my cursor somewhere special?
|

February 26th, 2003, 03:33 AM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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.
|

February 26th, 2003, 03:58 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
anyone? :-[
|

February 26th, 2003, 04:25 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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.
|

February 26th, 2003, 04:27 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
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.
|

February 26th, 2003, 09:13 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Quote: Originally posted by Scorpions4ever
Dude, you still didn't fix the bugs in your operator /= function yet -- check it carefully and you'll see what the problem is. |
duuuuuuuuuuh thank you.. im an idiot
|

February 26th, 2003, 11:01 PM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
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;
}
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|