473,656 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is a null pointer assignment error?

75 New Member
hai,
will someone please explain me what is null pointer assignment error.different persons say different reasons.some says the following code would generate null pointer assignment error.
#include<stdio. h>
#include<conio. h>
main()
{
int *p=NULL;
*p=10
getch();
}
as we try to access the memory 0 it causes an error.
but in my system i dont get this error.
i am using turbo c++ compiler.(windo w7 os)
Jan 8 '11 #1
3 5564
weaknessforcats
9,208 Recognized Expert Moderator Expert
The pointer p contains an address of 0. That is an invalid location for all programs. Depending upon your compiler, you will get a null assignment error at compile time or no error at compile time but an "access: error at run time.
Jan 8 '11 #2
donbock
2,426 Recognized Expert Top Contributor
I don't believe the C Standard requires that you be informed of this error. It only guarantees that a program that dereferences a null pointer will not work properly.
Jan 9 '11 #3
vivek nandan
9 New Member
you need to assign this pointer with address of some variable like ,
int *i;
int c=10;
i=&c;
//i=10 is an error as i is not a variable but a pointer to some memory!!
Jan 20 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

69
7422
by: Ken | last post by:
Hi all. When referring to a null pointer constant in C++, is there any reason to prefer using 0 over a macro called NULL that is defined to be 0? Thanks! Ken
51
3154
by: BigMan | last post by:
Does the C++ standard define what should happen in case of NULL pointer dereferencing. If not, does it say that it is illegal? Where, if so, does it say it?
10
26021
by: Denis Palmeiro | last post by:
Hello eveyone. What exactly is a NULL Pointer Dereference? I tried searching google but the only results that returned were bug reports. Some example code, if possible, would also be appreciated. Thanks in advance. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
3
7648
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
42
5909
by: junky_fellow | last post by:
Consider an implementation that doesn't use all bits 0 to represent a NULL pointer. Let the NULL pointer is represented by 0x12345678. On such an implementation, if the value of NULL pointer is printed will it be all 0's or 0x12345678 int main(void) { char *ptr; ptr = 0;
69
5547
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after assigning them their maximum defined values. However, the output of printf() for the long double 'ld' and the pointer of type void 'v_p', after initialisation don't seem to be right. The compiler used was gcc (mingw) with '-Wall', '-std=c99' and
5
5100
by: Angel Tsankov | last post by:
Does the standard define what happens when a NULL pointer is dereferenced? If so, where?
15
3753
by: khan | last post by:
Hi, I read that pointer representation can non-zero bit pattern, machine specific.Compiler when comes accross value '0' in pointer context, converts it to machine specific null pointer bit-pattern. My question is if a program refers to that specific value which is used by the machine to refer to null pointer, how compiler treats that?.
20
3212
by: prashant.khade1623 | last post by:
I am not getting the exact idea. Can you please explain me with an example. Thanks
8
6112
by: Rahul | last post by:
Please read the following code class Test{ public: void * operator new (size_t t) { return malloc(t); } void operator delete (void *p) { free(p); } };
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.