Re: Help in c pointers
- From: Pedro Graca <hexkid@xxxxxxxxxxx>
- Date: 28 Feb 2006 19:17:13 GMT
Jordan Abel wrote:
On 2006-02-28, Kenneth Brody <kenbrody@xxxxxxxxxxx> wrote:
"manochavishal@xxxxxxxxx" wrote:
int *p;
*p = 4;
char * msg;
*msg = 'c';
printf("msg is %s",msg);
Neither pointer has been initialized, and both assignments invoke UB.
Incidentally, there's a third instance of undefined behavior here -
anyone know what it is?
a) `msg' isn't (*) a c-string (a sequence of chars ending in NUL) so
passing it to printf invokes UB.
b) printf doesn't end with a newline nor is followed by a
fflush(stdout); invoking implementation defined behaviour (???)
(*) probably it is -- there probably is a nul between msg and msg+<some
large integer value>.
--
If you're posting through Google read <http://cfaj.freeshell.org/google>
.
- Follow-Ups:
- Re: Help in c pointers
- From: Jordan Abel
- Re: Help in c pointers
- References:
- Help in c pointers
- From: manochavishal@xxxxxxxxx
- Re: Help in c pointers
- From: Kenneth Brody
- Re: Help in c pointers
- From: Jordan Abel
- Help in c pointers
- Prev by Date: Re: Make fast money in the mail order buisness!
- Next by Date: Re: Random Number Generators....
- Previous by thread: Re: Help in c pointers
- Next by thread: Re: Help in c pointers
- Index(es):
Relevant Pages
|