i do some operations on an array
its all ok..
i dont get "accsses of cell beyong the array" anywhere when i fill the array.
but when i live the function i get
"Run-Time Check Failure #2 -Stack around the variable 'gh' was corrupted
??
i do some operations on an array
its all ok..
i dont get "accsses of cell beyong the array" anywhere when i fill the array.
but when i live the function i get
"Run-Time Check Failure #2 -Stack around the variable 'gh' was corrupted
??
C is like a loving parent. It likes you to learn from your mistakes. It's not going to stop you from wandering off the path into the tiger infested jungle. It knows that you'll eventually learn from your mistakes.
Even if that means you get mauled by a tiger.
C loves you.
Quzah.
Hope is the first step on the road to disappointment.
but i should get an error on some operation on the array
why it goes on the last line of the function
Why should it? Undefined behavior is just that, undefined. Anything can happen. That's why we get posts like "This code worked for me!" when they're copying stuff into pointers which haven't been assigned any value, etc. It MIGHT let you access that memory, it might not:Maybe it crashes, maybe it doesn't. Maybe it does for you, but not for me? Who knows. It's not defined.Code:int *x; *x = 10;
Quzah.
Hope is the first step on the road to disappointment.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
on codeblocks compiler it works fine
but on VS it gives me that run time error
??
No, in Code::Blocks, the error goes undetected - that is not the same as "works fine". That is, as quzah describes, one of the probems with undefined behaviour. Writing outside an array [which I'm fairly sure is what you are doing - posting your code would help a lot] is undefined behaviour, it may cause ANYTHING to happen, and "anything" includes "nothing that you actually notice" as well as crashes, nuclear launch and explosion of the hard-disk.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thanks i solved it
you are correct