Afficher un message
Vieux 17/10/2007, 12h35   #7
jacob navia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: AIX C compiler message unexplainable

Roberto Waltman wrote:
>
> void aaalib_trim (char *in) {
> int n = strlen(in) - 1;
> for ( ; n>= 0; n--)
> if (!isspace(in[n]))
> break;
> in[n+1] = '\0';
> }
>
> strlen(in) is always greater than 1, right?
>


strlen can be zero. Then, strlen(in)-1 is -1.
Since he tests for n>=0 the loop never gets
executed.
Then, in[n+1] == in[0] == 0 anyway since
strlen gave zero, so he overwrites a zero with a zero,
a harmless operation


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
  Réponse avec citation
 
Page generated in 0,05768 seconds with 9 queries