Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: NULL question not in FAQ Message-ID: <15616@smoke.brl.mil> Date: 28 Mar 91 22:10:20 GMT References: <1991Mar26.235643.4498@ux1.cso.uiuc.edu> <1991Mar27.194101.1685@grebyn.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 13 In article <1991Mar27.194101.1685@grebyn.com> ckp@grebyn.com (Checkpoint Technologies) writes: > int i = 0; > char *p = (char *)i; >So is it correct to interpret this code as unportable? It's not only not guaranteed to work in all standard-conforming C implementations, it may not even compile successfully, if "int" is not a suitable type for holding a pointer representation. (SOME integer type must do so, but not necessarily "int", which for example could be only 16 bits in a 24-bit address-space environment.) Basically, you should try to not use integer types to hold values of pointers. Usually it is simpler to use a pointer type all along.