On Mon, Dec 21, 2009 at 11:54:51PM -0700, ThanhVu (Vu) Nguyen wrote: > if the program is > char dest [100] = ""; > char *src = "hello world"; > sprintf(dest,src); > so if I want to change it to > snprintf(dest,src,sizeof(dest)); > then I am not sure which SizeOf to use ? should I use AddressOf something > here?
SizeOf is always the good one, provided you are facing a statically declared array (whose length is known at compile time). On the other hand, if you face a pointer to some area, you have no way to guess the good value (and sizeof will always return the size of a pointer, ie 4 or 8 depending on your architecture). This is the whole point in using snprintf: it's a piece of information that the compiler cannot figure out automatically, so we force the programmer to think about it and pass the (hopefully) correct value to snprintf. CIL won't be of any help here. Regards, -- Gabriel Kerneis ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users