クフでダローバルな日記

タフでもグローバルもない

Cポインタ問題

どうでしょう。

#include <stdio.h>

int main(){
	char *s1[]={"az","qxv"};
	char *s2[]={"We","must","go"};
	//文字の重複が無いようにしています
	char **ps[]={s1,s2};
/*
1.以下のそれぞれについて、何が出力されるか答えよ
//文字列
	printf("%s\n",*s1);
	printf("%s\n",**ps );
	printf("%s\n",*(*ps+1));
	printf("%s\n",*(*(ps+1)));
	printf("%s\n",*(*(ps+1)+1));
//文字(括弧の位置によってどう変わるか問う)
	printf("%c\n",***ps);
	printf("%c\n",*(**ps+1));
	printf("%c\n",**(*ps+1));
	printf("%c\n",***(ps+1));
	printf("%c\n",(***ps+1));
	printf("%c\n",*(**ps+3));
//おまけ
	printf("%c\n",**(*(ps+1)+1));
	printf("%c\n",*(*(*(ps+1)+2)+1));
/*
2.上のように宣言されている時、
printf("%c\n", hogehoge);
とすることでaが出力される方法をできるだけ多く考えよ。
ただし、結局同じようなことをしているものは同じものと見なす。
*/
}