![]() |
|
#1
|
|||
|
|||
Assertion ErrorHey
I have a page of code, now its not complete, but basically it will be a matrices calculator. But I am stuck on just entering the matrices. The assertion error (which ive read up on and says its basically a pointer error) is labelled below. Thing is this code compiled fine in visual studio at uni, and im using the same version of visual studio here at home. So i dont know why the error. I'm a relative beginner, and only just been taught the basics of pointers and structures so bare with me for ugly coding etc. Any help would be greatly appreciated Mitch CPP / C++ / C Code:
Thats not all of it, just one section of the code, Cheers for any help P.S. I've seen a lot of names from cprogramming.com, has the site shut down? Last edited by dsmith : 19-Feb-2004 at 22:58.
Reason: Changed code highlighting to C highlighting
|
|
#2
|
|||
|
|||
|
By the way, the attatched code.txt is the full code, not the same excerpt, just so you know if i'm making my declarations right etc
Cheers again, Mitch |
|
#3
|
||||
|
||||
|
I compiled and ran the code. It worked just fine. The code looks fine. I can't wait to start learning that stuff. We learned all the basics first semester and finished with structs and typedefs. All that stuff is pretty simple. I can't wait to get into linked lists and dynamic memory allocation so I can do some serious stuff... also want to learn to send and receive data across a network.
|
|
#4
|
||||
|
||||
|
Now that I think of it, I don't even have to wait for next semester. I'll just do it out of the book I bought for last semester. It had all that stuff in it, but we didn't even start covering classes. We're starting with classes at the beginning of next semester, so I'll be ready for that. I've already written a couple of them.
|
|
#5
|
||||
|
||||
|
Hi Mitch. I may have to look closer at your code. Malloc can be tricky.
One thing that jumped out at me is this: CPP / C++ / C Code:
Question: Is there allocated memory in these matrices for sure every time you call this? free is unpredictable (in some compilers) if there is not an associated malloc called before or if the ptr is not specifically set to null: Quote:
One thing that I do is put in a couple of fprintf statements to see exactly where things are breaking: CPP / C++ / C Code:
|
|
#6
|
|||
|
|||
|
no the first set of "free"'s wont have had a memory allocation happen before it, i just cant think of another (remotely efficient) way of freeing the memory allocation if i need to enter the matrix once, then realise a mistake has been made and enter them again. It needs to free that memory. Where can i put those lines to free any duplicate memory allocation whilst not having them run first time? maybe an if statement set if(counter>0){free_memory} and have counter set to 0 but counter++ everytime the function is called...
It IS breaking forst time every time. So it could well be that... Funny though that it would compile on one visual studio but not on another which should be exactly the same... Cheers to both for looking at it, and aaroncohn, you'll get you're chance, and the difficulty rating shoots up sharpish Thanks a lot, now all i have to do is try and get the other functions to work... Mitch |
|
#7
|
|||
|
|||
|
I put the if statement around the free's and it compiles fine now, thanks a lot dsmith. {i didnt put a counter, just an marker initialised to 0 and a marker=1 after the if statement (shockingly it was if(marker==1) ) }
Blinder, chers gents. Mitch |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in | ukrspp21 | MySQL / PHP Forum | 31 | 04-Jul-2006 22:41 |
| Including Maps and strings?? | maddie | C++ Forum | 17 | 05-Jul-2004 07:25 |
| error during program | rjd72285 | C++ Forum | 0 | 11-Nov-2003 19:49 |
| [script] E-mail webmaster error page | BobbyDouglas | PHP Code Library | 0 | 19-Aug-2003 21:10 |
| CD burner, focus or tracking error | ShingoDrrazz | Computer Hardware Forum | 1 | 09-Aug-2003 17:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The