| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: C++ for beginners? |
From: Tony Williams On 11/21/2004 08:12 PM, John Beckett wrote: > On Sun, 21 Nov 2004 19:13:19 -0500, "Geo" wrote: > >>Why wouldn't it work for strings? Strings are just arrays of characters and >>a character is simply a value like an int is a value. > > > I hope you realise that Tony's suggestion: > x ^= y ^= x ^= y; > was very tongue-in-cheek. Very > It is old folk lore that this magnificent code will swap the contents > of x and y, and programmers talk of days when such tricks were needed > to minimise use of data memory (particularly stack memory), at the > expense of code memory. > > I'm not sure whether anyone ever actually needed to use this code. > > The ^ (bitwise xor) operator is only defined for integer variables. It > is probably illegal (compiler error) with float or string. I didn't know that (no built in xor for float). Oh well, just get the address of the float, cast to char and iterate for sizeof(float). Ok, I'm kidding again. It's handy to be able to do stuff like that, but it's rarely a good idea. -- Tony --- BBBS/NT v4.01 Flag-5* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45) SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.