Re: how a pointer to null works .
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 02 Aug 2005 07:08:42 GMT
"sachin dooble" <sachin.dooble@xxxxxxxxx> writes:
> ranjan
> not very much sure but in turbo there will be compilation error.
> u can't have int *p=0 since here u have only declaration not
> definition .
> so u are trying to increase a undefined pointer .
> also in 4th line u are printing the value of the pointer in
> decimal format which will be in -ve
> this is because address should be printed in %u or %x form.
> so overall there will be a compilation error that's what i
> feel.
> Do inform me plz
Context, dammit! Don't assume that your readers can see the article
to which you're replying.
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
And please don't use abbreviations like "u" for "you" and "-ve" for
"negative". They just make what you write more difficult to read.
If you had been following this newsgroup, you would have seen this
advice many many times.
The code in the original post was:
#include<stdio.h>
int main()
{
int *p = 0;
++p;
printf("%d",p);
return 0;
}
There's actually nothing in that program that would cause a
compilation error (did you try it?). There are two instances of
undefined behavior. See Jack Klein's followup for a good explanation.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: how a pointer to null works .
- From: Default User
- Re: how a pointer to null works .
- References:
- how a pointer to null works .
- From: maadhuu
- Re: how a pointer to null works .
- From: sachin dooble
- how a pointer to null works .
- Prev by Date: Re: 'const' keyword problem
- Next by Date: Re: something to do with void *
- Previous by thread: Re: how a pointer to null works .
- Next by thread: Re: how a pointer to null works .
- Index(es):
Relevant Pages
|