Re: String reversing problem
- From: Christian Bau <christian.bau@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 22:23:26 +0000
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.
.
- Follow-Ups:
- Re: String reversing problem
- From: tmp123
- Re: String reversing problem
- References:
- String reversing problem
- From: Albert
- Re: String reversing problem
- From: slebetman@xxxxxxxxx
- Re: String reversing problem
- From: pai
- Re: String reversing problem
- From: Chuck F.
- Re: String reversing problem
- From: tmp123
- Re: String reversing problem
- From: Chuck F.
- Re: String reversing problem
- From: tmp123
- Re: String reversing problem
- From: Keith Thompson
- Re: String reversing problem
- From: tmp123
- Re: String reversing problem
- From: Christian Bau
- Re: String reversing problem
- From: tmp123
- String reversing problem
- Prev by Date: Re: gets() - dangerous? (Are we having fun yet?)
- Next by Date: Re: a big problem
- Previous by thread: Re: String reversing problem
- Next by thread: Re: String reversing problem
- Index(es):
Relevant Pages
|