S
saki
how can two variables be swapped without using a third variable?
a=a+b;
b=a-b;
a=a-b;
however we may not be able to swap pointers this way.
how can two variables be swapped without using a third variable?
saki said:a=a+b;
b=a-b;
a=a-b;
however we may not be able to swap pointers this way.
saki said:a=a+b;
b=a-b;
a=a-b;
however we may not be able to swap pointers this way.
I think you left out an important sentence here (maybe you did not
realize it was important): his tools put in a tab (as in '\t')
character.
This tab came through fine on *my* usenet server, so that the
inside of the loop was more-indented. It appears that whatever
software sits between you and Daniel Rudy, however, ate the tab.
The fact that some Usenet servers (and/or other Usenet article
delivery systems) eat tabs are why I have my software run all
my postings through the "expand" program by default.
Possibly, I suppose. The indents were pretty small though.
Brian
Now if your software is stripping tabs off, there's not much I can do
about it, Richard Heathfield.
Martin Ambuhl said:Or even integers, whether short or long or long long, whether signed
or unsigned,
or floating point numbers, whether float or double or long double.
There is _no_ type for which yours is an answer. That makes it worth
even less than the silly XOR trick.
return(0);
}
Now if your software is stripping tabs off, there's not much I can do
about it, Richard Heathfield.
Not if a=a+b; would wrap.Keith said:I think it actually works for unsigned integers.
Not if a=a+b; would wrap.
Richard said:Daniel Rudy said:
Chris Torek has already explained how he does something about it.
I stopped using tabs in C source years ago - I cannot now remember
whether Usenet was a factor in that decision, but it is not a
decision I have ever regretted.
Yeah, I know. I was too fast on the 'send' switch. Apologies to KeithRichard said:Joe Wright said:
Well, let's see, using 8-bit unsigned integer types.
a = 200;
b = 56;
a = a + b; a -> 0
b = a - b; b -> 200
a = a - b; b -> 56
Looks good to me. (That is, I am suggesting that it does in fact work
for unsigned integer types. I am not trying to suggest that it is a
good technique.)
Or any struct that can be copied with a shallow copy.user923005 said:Right, hence my comment:
"You are right in the case of fundamental types like integers and
doubles."
> Daniel Rudy wrote, On 07/04/07 18:02: ....
>
> It almost certainly is not Richard's software but some news servers. It
> may well not even be the news server Richard uses, merely some news
> server between you and Richard.
Dik said:It almost certainly is the software. I surmise that Richard's
software has no tabstops set, and the software is just expanding tabs
to the nearest tabstop (which there is not), and so gets deleted on a
reply and is not seen when reading. See also very old discussions in
net.lang.c about the use of tabs in posted articles. When the reader
uses tabstops different from the poster's setting, the article can
come out pretty mangled.
The use of tabs can be problematical for this reason, and that is also
why (I think) Default User had to expand tabs to spaces in his coding.
I suspect it is historic. At one point -Wall enabled all. Then
more were needed. In order to not disturb old makefiles, -W was
added.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.