字符串操作? [英] string operation??

查看:99
本文介绍了字符串操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

char str [10] =" string";

str [0] ^ = str [1];


任何人都可以告诉我在字符串中使用^运算符???


-Sethu

解决方案


se ***** @ gmail.com 写道:


大家好,

char str [10] =" string";

str [0] ^ = str [1];


任何人都可以告诉我在字符串中使用^运算符???



这不是手机。 "请"键入的次数比

plz多一点,并且移位键很容易找到。基本排版a)提高了你的信息的可读性和b)让读者觉得你需要付出一些努力。


现在问题。在str [0] ^ = str [1]中。你没有使用

字符串,而是使用该字符串中的字符。我们用前两个字符按位或者操作
,然后将

结果存储在第一个字符中。代码为什么这样做是超出我的,尽管

我怀疑这是一种原始的加密技术....


se*****@gmail.com 写道:


大家好,

char str [10] =" string";

str [0] ^ = str [1];


任何人都可以告诉我在字符串中使用^运算符???



请避免使用像plz这样的缩写而不是取悦,因为这是一个

国际论坛,许多海报可能都不知道它的含义。


采用str [1]的char值的位模式,并使用char值的位模式完成一个独占的

OR操作在str [0]

,结果存储回str [0]。


^ =是复合赋值运算符。


in 707477 20061127 112944" santosh" < sa ********* @ gmail.comwrote:


> se ***** @ gmail.com写道:


> hi everybody,

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

任何人都可以告诉我在字符串中使用^运算符???


请避免使用像plz这样的缩写而不是取悦,因为这是一个
国际论坛,很多海报可能都不知道它的含义。
获取str [1]处的char值的位模式,并使用str [0]
处的char值的位模式进行异或运算,并将结果存储回str [0]。

^ =是复合赋值运算符。



操作员两侧的空格更清楚

(尤其是Pascal程序员)。


hi everybody,

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

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

-Sethu

解决方案


se*****@gmail.com 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....


se*****@gmail.com wrote:

hi everybody,

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

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

Please avoid abbreviations like plz instead of please, since this is an
international forum and many posters may not know it''s meaning.

The bit pattern of the char value at str[1] is taken and an exclusive
OR operation is done with the bit pattern of the char value at str[0]
and the result in stored back to str[0].

The ^= is a compound assignment operator.


in 707477 20061127 112944 "santosh" <sa*********@gmail.comwrote:

>se*****@gmail.com wrote:

>hi everybody,

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

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


Please avoid abbreviations like plz instead of please, since this is an
international forum and many posters may not know it''s meaning.

The bit pattern of the char value at str[1] is taken and an exclusive
OR operation is done with the bit pattern of the char value at str[0]
and the result in stored back to str[0].

The ^= is a compound assignment operator.

Which would be clearer with spaces either side of the operator
(especially to a Pascal programmer).


这篇关于字符串操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆