1
在下面的程序,- * - 指针操作?
int main()
{
char a[] = "azmruf";
char *ptr = a;
ptr += 5;
//Now ptr points at 'f'
printf("%c", --*ptr--); //e got printed. Bcos of post increment now ptr in u.
printf("%c", *ptr); // so 'u' got printed now.
// Next --*--ptr becomes --*(--ptr),
// ptr is moved to r, then --r i.e q is printed, but pointer should
// be in 'r'
printf("%c", --*--ptr);
//Im here getting 'q' only instead of 'r'. There is no 'q' in my string.(??!!!)
printf("%c", *ptr);
return 0;
}
..不过,我在最后的printf获得 'Q'()?
我希望这不是生产代码! – 2013-02-15 05:23:11
@JonathanGrynspan,它的非生产代码。仅学习目的。 – Jeyaram 2013-02-15 05:24:06
@Jeyaram你从中学到了什么?如何在混淆的C constest中获胜? – 2013-02-15 05:30:26