Re: String reversing problem



In article <1135980646.561628.174380@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"tmp123" <tmp123@xxxxxxxxx> wrote:

> To Mr. Keith Thompson and Mr. Tim Rentsch:
>
> Thanks for your replies, always open to learn something new.
> The first comment mades me doubt: if strlen(s)==0, s==e, thus s!=e-- is
> false and exit loop.
> The second comments, about sequence points, well, I must recognize I do
> not know what do you refer as "sequence points". An explanation or a
> reference will be welcome.
>
> To Mr. Christian Bau:
>
> Your English seems not to be the most valid to be used in net, because
> could be easily confused with agressive, specially by non-English
> people. Moreover, it could be taken as a confusion between what is a
> medium to interchange knowledgment, and what is a real programming
> team.

Nothing wrong with my english. Lots wrong with your code. I don't care
too much about the undefined behavior, because you managed to write
completely incomprehensible code for a very simple task.

void reverse_string (char* s)
{
int i = 0;
int j = strlen (s) - 1;

while (i < j)
{
char tmp = s [i];
s [i] = s [j];
s [j] = tmp;
++i;
--j;
}
}

works and is easy to understand.
.



Relevant Pages

  • Re: David Dryden re: Levels of Functional Complexity
    ... the word "penny" in the English language system. ... specifically defined as five fully specified characters given an ... idea of penny across - such as the sequence pinny or piny or peny. ...
    (talk.origins)
  • Re: Gaza Through the Looking Glass
    ... I read the English and paraphrase. ... it's a reading of the text. ... I see the sequence as saying that. ... God saw that it was good" there is no record of Him saying it to ...
    (soc.culture.jewish.moderated)
  • Re: David Dryden re: Levels of Functional Complexity
    ... the word "penny" in the English language system. ... specifically defined as five fully specified characters given an ... idea of penny across - such as the sequence pinny or piny or peny. ...
    (talk.origins)
  • Re: origin of the first alphabet
    ... >>the phonology is not normally accessible to a native speaker. ... I peceive them as a sequence. ... > their names in English, of course) are, from back to front, u o a e i. ...
    (sci.lang)
  • Re: Machines and people
    ... >Boolean Algebra lead to letters such as a,b,c,..etc. ... This standard specifies that 8 bits arranged in a certain sequence stand ... for the character 'A'; another sequence stands for the character 'a'. ... The basic answer to your question is that the bits get to be English ...
    (Debian-User)