Re: string operation??
- From: Christopher Benson-Manica <ataru@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 19:54:16 +0000 (UTC)
mark_bluemel@xxxxxxxxx wrote:
char str[10]="string";
str[0]^=str[1];
Now to the question. In "str[0]^=str[1]" you are not operating on a
string, but on a character in that string. We are doing an exclusive
bitwise or operation with the first two characters and storing the
result in the first. Why the code is doing that is beyond me, though
I'd suspect it was a crude cryptographic technique....
Is it implementation-defined whether the above code yields undefined
behavior or not? (If char is signed, may str[0]^=str[1] not generate
a trap representation?)
--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
.
- Follow-Ups:
- Re: string operation??
- From: Spiros Bousbouras
- Re: string operation??
- From: Random832
- Re: string operation??
- References:
- string operation??
- From: sethukr@xxxxxxxxx
- Re: string operation??
- From: mark_bluemel
- string operation??
- Prev by Date: Re: screen clearing in ANSI C
- Next by Date: Urgently required
- Previous by thread: Re: string operation??
- Next by thread: Re: string operation??
- Index(es):
Relevant Pages
|
|