3ec Subj : Re: Codeguard found error in sprintf() To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Fri Feb 27 2004 01:38 pm Richard Hufford wrote: >Is it possible to have Codeguard notice if buf is too small and ignore >whatever size r is? I can disable memory access error in sprintf, but won't >that also disable notifying me that buf is too small? >> >> char buf[100]; >> char *r = new char[8]; >> strcpy (r, "richard"); >> sprintf (buf, "%25s", r); Does CG complain about char buf[100]; sprintf (buf, "%25s", "richard" ); How about char buf[100]; char *r = new char[26]; strcpy (r, "richard"); sprintf (buf, "%25s", r); That should stop the complaining. You could even do this char buf[100]; #ifdef _CG_ char *r = new char[26]; #else char *r = new char[8]; #endif strcpy (r, "richard"); sprintf (buf, "%25s", r); Just make sure you aren't bypassing an actual error... . 0