Re: string operation??




sethukr@xxxxxxxxx wrote:
hi everybody,

char str[10]="string";
str[0]^=str[1];

can anybody plz tell me the use of ^operator in string???

This isn't a mobile phone. "please" is only a little more typing than
"plz", and the shift key is easy to find. Basic typography a) improves
the readibility of your message and b) makes the reader feel that you
bothered to put in some effort.

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....

.



Relevant Pages

  • Re: Advice needed binary configuration files
    ... Just typing for something to do. ... convert the character buffer to the long type. ... And so on and so on till you get to the string. ... Regards, ...
    (microsoft.public.vc.mfc)
  • Re: replace substring
    ... The OP should tell how he got that invalid string literal. ... own typing, he should replace the backslashes with pairs of backslashes, ... on the course of copying each character to a separate character array. ...
    (comp.lang.c)
  • Re: Replacing values
    ... Changing a ' to a " is as simple as typing a different character. ... In your example you are typing a string literal so typing it differently ... #if I do puts m ...
    (comp.lang.ruby)
  • Re: CAN I REPLACE NON-PRINTING CHAR(127) WITH A SYMBOL?
    ... and specify Other as the character. ... And I hit and held the alt-key while typing 0127 on the numeric keypad to get ... HAVE A FILE WITH A STRING OF TEXT BROKEN BY CHAR. ...
    (microsoft.public.excel.programming)
  • Re: Need Symbol to Indicate a Space in a Computer Address String
    ... ^ This character is above the ... on my keyboard. ... > When typing a string e.g. rmfn, eg. where can I find the symbol ...
    (microsoft.public.word.docmanagement)