When compiling with Turbo C++ - are you generating a 16-bit small memory
model application? In that case, the NULL pointer is mapped to the start
of the data segment within the program, i.e. a NULL pointer operation
doesn't touch any memory outside of the application, and there are no
read/write protection of memory. When the application ends, the Turbo C++
runtime library checks a private variable stored first in the data
segment. If that variable has been changed, the application has done
assignments through a NULL pointer and the error message is printed.
When building 16-bit applications in large memory model, the NULL pointer
is mapped to a critical memory area in MS-DOS. When the machine gets
interrupts (keyboard presses, timer interrupts, hard disk activity etc),
this critical area specifies memory addresses to handlers to process the
interrupts. In case of a NULL-pointer assignment, one or more of these
addresses will be overwritten and the machine will hang.
For 32-bit applications (Win32, Linux etc) the application is running in
an environment where the memory is hardware-supervised. A NULL pointer
here points to a memory area that is read/write-protected. As soon as the
application tries to follow the NULL-pointer, the OS catches the illegal
access and kills the application - or lets a debugger display the
offending instruction in case you use a development environment.
/Per W
On Fri, 20 Aug 2004, Daniel K. O. wrote:
> Abhijeet S wrote:
>
> > this is the program I have written.. this works fine on Turbo C++
> > except that in the end it gives a null pointer assignment after giving
> > the output. in DevC++ it just accepts the input and crashes.. can
> > anyone tell me why.. I tried using the while loop structure too but
> > same error also tried finding out the length of the sting and then
> > using that in the for loop
> > anyways.. I guess I'm going in the wrong direction so can anyone help
> > me out ?
>
>
> This was already answered (by me) to your previous e-mail. It's time to
> learn what "memory allocation" means. Any good book/tutorial have this
> topic. (where are you learning C++ from?)
>
>
> Daniel K. O.
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|