On 5 Sep., 13:20, sam <sameer...@gmail.comwrote:
Hi,
* * *I just want to ask the question about this code
int len =0; len =5;
*"x41" * (len);
*In this is "x41" is multiply by 5 or it just can acquire space like
this
x41x41x41x41x41 .
I am a newbie and i am confused , If you can't understand this
question i *am sorry, but i just want the clarification of this code.
The code you cite is not something you should waste your time with, it
seems to be part of an obfuscated program (intentionally written to be
hard to understand), or written by a real first-timer, or it may be
wrongly presented here.
int len = 0; len = 5;
This is identical to:
int len = 5;
The snippet:
"x41" * (len);
This is not valid in C++, you cannot multiply a const char array of
length 4 with an int. Old compilers for C and C++ may interpret this
as:
(int) "x41" * len;
This expression uses the memory address of the string constant "x41",
which may vary on each run of the program, and multiplies it with 5
(the content of the variable len). The round braces around len are
unneeded. Absent any instruction on what to do with the result of the
expression, it is then discarded - i.e. the whole line does nothing
and my be outright optimized away by the compiler. I assume there is
something missing in the code snippet you give.
best,
MiB.