C言語なら俺に聞け(入門篇) Part 16

このエントリーをはてなブックマークに追加
929えいいち ◆GRGSIBERIA
>>918
#include <iostream>
using namespace std;

int main(){
int a, b;
int c, d;
int *p;

p = &a;

*p = 0;
cout << a << "-" << *p << "\n";
//cout << &a << "-" << p << "\n";

p--;
*p = 1;
cout << b << "-" << *p << "\n";
//cout << &b << "-" << p << "\n";
930えいいち ◆GRGSIBERIA :2007/07/23(月) 21:44:13
p--;
*p = 2;
cout << c << "-" << *p << "\n";
//cout << &c << "-" << p << "\n";

p--;
*p = 3;
cout << d << "-" << *p << "\n";
//cout << &d << "-" << p << "\n";

return 0;
}

別にdからでも動くと思います。