I have a program that works fine under windows, but when i run it on Unix I get a very slightly diffent set of results, followed by a 'segmentation fault' message. I'm at a loss to explain why. Any ideas?
evinkeating
0
Newbie Poster
Recommended Answers
Jump to PostYes, there's an error in your code.
Jump to PostBecause undefined behaviour can result in pretty much any behaviour, especially if it involves invalid pointer accesses.
Jump to Post/* initialise triangular matrix to zero */ for(i =0; i < dimention; ++i) for(j =0; j <= i+1; ++j) lower_tri[i][j] = 0;
The above causes buffer overrun. The inner loop should be < not <=
All 10 Replies
Aranarth
126
Posting Whiz in Training
evinkeating
0
Newbie Poster
Aranarth
126
Posting Whiz in Training
kings_mitra
-1
Junior Poster
evinkeating
0
Newbie Poster
kings_mitra
-1
Junior Poster
evinkeating
0
Newbie Poster
evinkeating
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
evinkeating
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.