倩åœã«ãããèšèªå ¥éããããµæ§é äœ verïŒ.2130
ððè€æ°ã®æååããŒã¿ãïŒã€ã®é å宣èšã䜿ãåæã«ã¡ã¢ãªã«æ ŒçŽããŠã¿ãŸãããã®ïŒ
ððè€æ°ã®æååããŒã¿ãïŒã€ã®é å宣èšã䜿ãåæã«ã¡ã¢ãªã«æ ŒçŽããŠã¿ãŸãããã®ïŒ
ãœãŒã©ãŒãä»åã¯ã
ïŒã€ã®é å宣èšã䜿ã£ãŠè€æ°ã®æååããŒã¿ãã¡ã¢ãªã«æ ŒçŽ
ããŠã¿ãããšããããŸãã
ïŒã€ã®é å宣èš
char str[]="apple";
char ars[]="ringo";
char arr[]="cashewnuts";
ã
ïŒã€ã®ãã€ã³ã¿å€æ°å®£èš
char* str="apple";
char* ars="ringo";
char* arr="cashewnuts";
ã
ã€ããããšã«ãã£ãŠãã³ã³ãã¥ãŒã¿ã®ã¡ã¢ãªã«åã蟌ãã§ããæ ŒçŽããŠãã
ã"apple"ã"ringo"ã"cashewnuts"ã®æååããŒã¿ã
ããããããããðãäžã€ã®é å宣èšãð
ãããããðchar hairetu[3][11]={"apple","ringo","cashewnuts"};ð
ãè¡ãããšã«ãã
ãŸãšããŠã¡ã¢ãªã«ãšãããããšãã§ããŸã
ããããªïœãã¢ã¬ãµ
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ãã®ãããªé åã®èšè¿°ãè¡ãããšã«ãã
"apple"ã"ringo"ã"cashewnuts"ã®æååããŒã¿ã
ïŒåºŠã«ã¡ã¢ãªã«æ ŒçŽããããšãã§ãããã ãã
ä»ãŸã§ã®ããã«
"apple"ã"ringo"ã"cashewnuts"ã®ãããª
ç°ãªãïŒã€ã®æååããŒã¿ãã³ã³ãã¥ãŒã¿ã®ã¡ã¢ãªã«ãšããããšã
é å宣èšãããã¯ãã€ã³ã¿å€æ°å®£èšãïŒã€ãããªããªããŠããããã ã
ã¢ã¬ãµãïŒã€ã®é å宣èš
char str[]="apple";
char ars[]="ringo";
char arr[]="cashewnuts";
ãå®è¡ããŠ
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ãã
ã³ã³ãã¥ãŒã¿ã®ã¡ã¢ãªã«åã蟌ãã 次ã®ããã°ã©ã
ð
#include <stdio.h>
int main(void){
char str[]="apple";
char ars[]="ringo";
char arr[]="cashewnuts";
printf("%s\n",str);
printf("%s\n",ars);
printf("%s\n",arr);
return 0;
}
ã³ã³ãã€ã«çµæ
apple
ringo
cashewnuts
ã
ïŒã€ã®ãã€ã³ã¿å€æ°å®£èš
char* str="apple";
char* ars="ringo";
char* ars="cashewnuts";
ãè¡ã
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
ã³ã³ãã¥ãŒã¿ã®ã¡ã¢ãªã«åã蟌ãã 次ã®ããã°ã©ã
ð
include <stdio.h>
int main(void){
char* str="apple";
char* ars="ringo";
char* arr="cashewnuts";
printf("%s\n",str);
printf("%s\n",ars);
printf("%s\n",arr);
return 0;
}
ã³ã³ãã€ã«çµæ
apple
ringo
cashewnuts
ð
ãããã®ããã°ã©ã ã¯
ãããããããïŒã€ã®é å宣èš
ããchar hairetu[3][11]={"apple","ringo","cashewnuts"};
ã䜿ãããšã«ãã£ãŠ
ç°¡ç¥åãããŠ
次ã®ããã«ãããããããŸãã
#include <stdio.h>
int main(void){
char hairetu[3][11]={"apple","ringo","cashewnuts"};
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
return 0;
}
ã³ã³ãã€ã«çµæ
apple
ringo
cashewnuts
ãœãŒã©ãŒãããã£ãã ãã¶ããã£ãããããã
ãã£ãã
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ãå®è¡ããããš
äœããããªãããŠããã®ã
ãšããããšã ãã
ãŸã
char hairetu[3][11]ã®éšåããããª
char hairetu[3][11]ã¯ïŒæ¬¡å é åãšãªã£ãŠããŠ
char hairetu[3][11];
ãå®è¡ããããš
é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ãçæãããŸã
ãããŠ
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ãå®è¡ããããš
é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ã«
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
hairetu[0][0]='a';
hairetu[0][1]='p';
hairetu[0][2]='p';
hairetu[0][3]='l';
hairetu[0][4]='e';
hairetu[0][5]='\0';
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
ã«ã¯æååããŒã¿ã¯æ ŒçŽãããŸããããã®å Žåãã«æå\0ãæ ŒçŽãããããšã«ãªããŸã
hairetu[1][0]='r';
hairetu[1][1]='i';
hairetu[1][2]='n';
hairetu[1][3]='g';
hairetu[1][4]='o';
hairetu[1][5]='\0';
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
ã«ã¯æååããŒã¿ã¯æ ŒçŽãããŸããããã®å Žåãã«æå\0ãæ ŒçŽãããããšã«ãªããŸã
hairetu[2][0]='c';
hairetu[2][1]='a';
hairetu[2][2]='s';
hairetu[2][3]='h';
hairetu[2][4]='e';
hairetu[2][5]='w';
hairetu[2][6]='n';
hairetu[2][7]='u';
hairetu[2][8]='t';
hairetu[2][9]='s';
hairetu[2][10]='\0';
ãšæååããŒã¿ãæ ŒçŽãããŸã
ã€ãŸã
"apple"ãð1
"ringo" ð2
"cashewnuts" ð3
ãæ ŒçŽããããã«
char hairetu[3][11]ã®
[3]ã¯èŠçŽ æ°ã
ãããŠ
æååããŒã¿
cashewnutsïŒ10æåïŒ
ã
\0(ãã«æåïŒ
ãšããããŠ
11æåæ ŒçŽããããã«
char hairetu[3][11]ã®
[11]ã¯èŠçŽ æ°ã11ãšãªã£ãŠãããã ããã
ãã®ããšã瀺ãããã°ã©ã ã¯ãã¡ãã§ã
ð
#include <stdio.h>
int main(void) {
char hairetu[3][11] = { "apple","ringo","cashewnuts" };
printf("%s\n", hairetu[0]);
printf("%s\n", hairetu[1]);
printf("%s\n", hairetu[2]);
printf("%c\n", hairetu[0][0]);
printf("%c\n", hairetu[0][1]);
printf("%c\n", hairetu[0][2]);
printf("%c\n", hairetu[0][3]);
printf("%c\n", hairetu[0][4]);
printf("%c\n", hairetu[0][5]);
printf("%c\n", hairetu[0][6]);
printf("%c\n", hairetu[0][7]);
printf("%c\n", hairetu[0][8]);
printf("%c\n", hairetu[0][9]);
printf("%c\n", hairetu[0][10]);
printf("%c\n", hairetu[1][0]);
printf("%c\n", hairetu[1][1]);
printf("%c\n", hairetu[1][2]);
printf("%c\n", hairetu[1][3]);
printf("%c\n", hairetu[1][4]);
printf("%c\n", hairetu[1][5]);
printf("%c\n", hairetu[1][6]);
printf("%c\n", hairetu[1][7]);
printf("%c\n", hairetu[1][8]);
printf("%c\n", hairetu[1][9]);
printf("%c\n", hairetu[1][10]);
printf("%c\n", hairetu[2][0]);
printf("%c\n", hairetu[2][1]);
printf("%c\n", hairetu[2][2]);
printf("%c\n", hairetu[2][3]);
printf("%c\n", hairetu[2][4]);
printf("%c\n", hairetu[2][5]);
printf("%c\n", hairetu[2][6]);
printf("%c\n", hairetu[2][7]);
printf("%c\n", hairetu[2][8]);
printf("%c\n", hairetu[2][9]);
printf("%c\n", hairetu[2][10]);
return 0;
}
ãã«ãå®è¡çµæ
apple
ringo
cashnuts
a
p
p
l
e
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
r
i
n
g
o
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
ïŒç©ºçœïŒ
c
a
s
h
e
w
n
u
t
s
ïŒç©ºçœïŒ
ã¡ãã£ãšããŸãðª
é åå€æ°
hairetu[2][10]ã«ã¯ãã«æåããŒã¿'\0'ãæ ŒçŽãããŠããŸã
printf("%c\n", hairetu[2][10]);
ã®å®è¡çµæã¯
ïŒç©ºçœïŒã§ãã
%cåºåå€ææå®åã%dåºåå€ææå®åã«åãæ¿ãã
printf("%d\n", hairetu[2][10]);
ã®å®è¡çµæã¯
0ã«ãªããŸã
ã€ãŸã
ãã«æåããŒã¿'\0'ïŒç©ºçœïŒã®ã¢ã¹ããŒã³ãŒãã¯0ã«ãªã£ãŠããŸã
ã¢ã¹ããŒã³ãŒãã%cåºåå€ææå®åãçšããŠprintfåºå衚瀺ãããš
æåããŒã¿ã衚瀺ãããã®ã§ãããðª
ãã®ããã°ã©ã ã®å Žå
ã¢ã¹ããŒã³ãŒã0ã%cåºåå€ææå®åãçšããŠprintfåºå衚瀺ããŠããã®ã§
ãã«æåããŒã¿'\0'ããªãã¡ã空çœã衚瀺ãããŠããŸãðª
ã¢ã¹ããŒã³ãŒã0ã%dåºåå€ææå®åãçšããŠprintfåºå衚瀺ãããš
ïŒã衚瀺ãããããšã«ãªããŸãðª
ãœãŒã©ãŒããïœãŠãããã§è³ªåã§ïœãã
ã¢ã¬ãµããã®ãšã
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
ãªã«ãè¡šèšæ³ãããããããšæãããŸããã
%såºåå€ææå®åãçšããããŠãã
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
ã®
hairetu[0]
hairetu[1]
hairetu[2]
ã«åœããéšåã«ã¯
ãã€ã³ã¿å€æ°ãä»£å ¥ãããªããã°ãªããŸããã
hairetu[0]
hairetu[1]
hairetu[2]
ã¯
é åå€æ°ã§
ãã€ã³ã¿å€æ°ã«èŠããªããããªæ°ãããŸãã
ãã€ã³ã¿å€æ°ãšãªã£ãŠããŸããã
ã¿ãªãïœã
ð¥ãð§ãðŠããðããð€ãã. . .
ä»æ¥ã¯ã©ããªã話ãã§ãŠããã®ããªð
ð¥ãð§ãðŠããðããð€ãã. . .
ããããã»ã»ã»
ããã§ã¯ã
ãœãŒã©ãŒãã
ç¶ããããããããŸããã
ãœãŒã©ãŒããµã€ã
printf("%s\n",hairetu);ã®
ããããããããããããð¥hairetuð¥ã¯
é åhairetuããã€ã³ã¿å€æ°hairetuãã€ãã£ãŠ
æååããŒã¿ãã¡ã¢ãªã«æ ŒçŽããããšã
ãã®æååããŒã¿ãæ ŒçŽãããŠããã¡ã¢ãªé åã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ã
æ ŒçŽããŠãããã€ã³ã¿å€æ°ã§ããã
åæã«
æååããŒã¿ãæ ŒçŽããŠããã¡ã¢ãªã代衚ããã¢ãã¬ã¹ã§ããããŸããã
âããâããâããâããâããâ
ðããã®éšåã
ã¡ãã£ãšã ãè£è¶³ããŸïœã
以åã®ãšããœãŒãã§åŠãã ããšã®ããããã«ãªããŸãã
é åhairetuããã€ã³ã¿å€æ°hairetuãã€ãã£ãŠ
"apple"
ã®ãããª
æååããŒã¿ãã¡ã¢ãªã«æ ŒçŽããããšã
é åå€æ°
hairetu[0]
hairetu[1]
hairetu[2]
hairetu[3]
hairetu[4]
hairetu[5]
ã«ã¯
æååããŒã¿"apple"ã®
'a'
'p'
'p'
'l'
'e'
'\0'
ãæ ŒçŽãããããšã«ãªããŸãã
é åå€æ°
hairetu[0]
ã«ã¯
æååããŒã¿"apple"ã®å é ã®æåããŒã¿'a'ãæ ŒçŽãããŠããŸã
ãããŠ
hairetuã¯
é åå€æ°
hairetu[0]
ã®ã¢ãã¬ã¹ãšãªã£ãŠããŸã
ãããããããããããããããsolarplexussãã
âããâããâããâããâããâ
ãããŠ
æååããŒã¿ã
printfåºå衚瀺ãããšãã«ã¯
%såºåå€ææå®åããã¡ããŠ
printf("%s\n",hairetu);
ã®ããã«
æååããŒã¿ãæ ŒçŽãããŠããã¡ã¢ãªé åã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽããŠãã
ããããããããã€ã³ã¿å€æ°ð¥hairetuð¥ãã
çšããããŸãã
ããã§
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ãè¡ãããŠ
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ã«
hairetu[0][0]='a';
hairetu[0][1]='p';
hairetu[0][2]='p';
hairetu[0][3]='l';
hairetu[0][4]='e';
hairetu[0][5]='\0';
ãšæ ŒçŽãã
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
ã«ã¯æååããŒã¿ã¯æ ŒçŽãããŸããããã®å Žåãã«æå\0ãæ ŒçŽãããããšã«ãªããŸã
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
ã«ã¯
hairetu[1][0]='r';
hairetu[1][1]='i';
hairetu[1][2]='n';
hairetu[1][3]='g';
hairetu[1][4]='o';
hairetu[1][5]='\0';
ãšæååããŒã¿ãæ ŒçŽãã
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
ã«ã¯æååããŒã¿ã¯æ ŒçŽãããŸããããã®å Žåãã«æå\0ãæ ŒçŽãããããšã«ãªããŸã
é åå€æ°
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ã«ã¯
hairetu[2][0]='c';
hairetu[2][1]='a';
hairetu[2][2]='s';
hairetu[2][3]='h';
hairetu[2][4]='e';
hairetu[2][5]='w';
hairetu[2][6]='n';
hairetu[2][7]='u';
hairetu[2][8]='t';
hairetu[2][9]='s';
hairetu[2][10]='\0';
ãšæååããŒã¿ãæ ŒçŽãããããšã«ãªããŸã
ãã®å Žå
ã©ã®ããã«
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
ã³ãã³ãããã³ããç»é¢ã«printfåºå衚瀺ãããããããšããããšã§ããã
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ãæ ŒçŽããŠããå é ã®é åå€æ°ã¯
ãããã
hairetu[0][0]
hairetu[1][0]
hairetu[2][0]
ãšãªã£ãŠããŸã
ã§ãã®ã§
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã衚瀺ããã®ã«
hairetu[0][0]
hairetu[1][0]
hairetu[2][0]
ã®ã¢ãã¬ã¹
&hairetu[0][0]
&hairetu[1][0]
&hairetu[2][0]
ãçšããŠ
次ã®ãããªããã°ã©ã ãæ§æããã°
ãããããã
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ãprintfåºå衚瀺ã§ãããããªããããŸãã
include <stdio.h>
int main(void) {
char hairetu[3][11] = { "apple","ringo","cashewnuts" };
printf("%s\n", hairetu[0][0]);
printf("%s\n", hairetu[1][0]);
printf("%s\n", hairetu[2][0]);
return 0;
}
ã³ã³ãã€ã«çµæ
äœã衚瀺ãããŸãã
ãœãŒã©ãŒãïŒïŒïŒ
ãªããããããããªã»ã»ã»
ãŸã¡ãããŸããã
printf("%s\n", hairetu[0][0]);
printf("%s\n", hairetu[1][0]);
printf("%s\n", hairetu[2][0]);
ã§ã¯ãªã
printf("%s\n", &hairetu[0][0]);
printf("%s\n",&hairetu[1][0]);
printf("%s\n",&hairetu[2][0]);
ã§ããã
&ãä»ãå¿ããŠããŸãã
ããã°ã©ã ãæžãçŽããŠãã«ãå®è¡ããŠã¿ããš
#include <stdio.h>
int main(void) {
char hairetu[3][11] = { "apple","ringo","cashewnuts" };
printf("%s\n",&hairetu[0][0]);
printf("%s\n",&hairetu[1][0]);
printf("%s\n",&hairetu[2][0]);
return 0;
}
ãã«ãå®è¡çµæ
apple
ringo
cashewnuts
ãœãŒã©ãŒããã®ããã°ã©ã ãå®è¡ããŠ
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
ã³ãã³ãããã³ããç»é¢ã«printfåºå衚瀺ã§ããŠããŸãã
å®ã¯
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ã
ã³ãã³ãããã³ããç»é¢ã«printfåºå衚瀺ãããšãã¯
printf("%s\n",&hairetu[0][0]);
printf("%s\n",&hairetu[1][0]);
printf("%s\n",&hairetu[2][0]);
ã§ãªã
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
ãšèšè¿°ãããšããä»çµã¿ã«ãªã£ãŠããŸãã
ããããé åhairetu[0]ã«æååããŒã¿"apple"ãæ ŒçŽãããŠããŠ
ãã®é åhairetu[0]ã®ã¢ãã¬ã¹ãæ ŒçŽããŠãããã€ã³ã¿å€æ°ã
hairetu[0]
ã«ãªã£ãŠãããšããæãã§ã
ããããããããðððãã®ä»çµã¿ã¯ððð
ðððãã€ã³ã¿å€æ°ã®ã¢ãã¬ã¹ãæ ŒçŽãããã€ã³ã¿å€æ°ðððã®ãšããœãŒãã§è©³ãã解説ãããŠããŸïœãððð
ã§ãã®ã§
æååããŒã¿
"apple"
"ringo"
"cashewnuts"
ãprintfåºå衚瀺ãããšãã¯
#include <stdio.h>
int main(void) {
char hairetu[3][11] = { "apple","ringo","cashewnuts" };
printf("%s\n", hairetu[0]);
printf("%s\n", hairetu[1]);
printf("%s\n", hairetu[2]);
return 0;
}
ã®ããã«
ããã°ã©ã ãèšè¿°ããŸã
ãã®ãšãã®
ããããããããããããããã
ããããããããããããð¥hairetu[0]ð¥ã¯
æååããŒã¿"apple"ãæ ŒçŽããŠããé£ç¶ããã¡ã¢ãªã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽãããã€ã³ã¿å€æ°
ããããããããã
ããããããã
ããããããããããããð¥hairetu[1]ð¥ã¯
æååããŒã¿"ringo"ãæ ŒçŽããŠããé£ç¶ããã¡ã¢ãªã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽãããã€ã³ã¿å€æ°
ããããããããããããããããã
ããããããããããããð¥hairetu[2]ð¥ã¯
æååããŒã¿"cashewnuts"ãæ ŒçŽããŠããé£ç¶ããã¡ã¢ãªã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽãããã€ã³ã¿å€æ°
ã®åœ¹å²ãã¯ãããŠããŸãã
ã€ãŸã
é åå€æ°
hairetu[0]
hairetu[1]
hairetu[2]
ã¯
æååããŒã¿
"apple"
"ringo"
âcashewnutsâ
ã
æ ŒçŽããŠããé£ç¶ããã¡ã¢ãªé åã®
å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽããŠãã
ãã€ã³ã¿å€æ°ãšãªã£ãŠããã®ã§ããã
ã€ãã§ã«
é åå€æ°
hairetu[0]
hairetu[1]
hairetu[2]
ãæ ŒçŽããŠããã¢ãã¬ã¹ã
次ã®ããã°ã©ã ã§è¡šç€ºããŠã¿ãããšæããŸãã
#include <stdio.h>
int main(void){
char hairetu[3][11] = { "apple","ringo","cashewnuts" };
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
printf("%p\n",hairetu[0]);
printf("%p\n",hairetu[1]);
printf("%p\n",hairetu[2]);
return 0;
}
ã³ã³ãã€ã«çµæ
EAZY IDECã®å Žå
apple
ringo
cashewnuts
0019FF37
0019FF42
0019FF4D
Visual Studioã®å Žå
apple
ringo
cashewnuts
003FF8C8
003FF8D3
003FF8DE
ãœãŒã©ãŒã
printf("%s\n",hairetu[0]);
printf("%s\n",hairetu[1]);
printf("%s\n",hairetu[2]);
ãå®è¡ãããããšã«ãã
æåå
apple
ringo
cashewnuts
ã
ã³ãã³ãããã³ããç»é¢ã«è¡šç€ºãããŸãããã
ã€ãŸã
hairetu[0]
hairetu[1]
hairetu[2]
ã¯
æååããŒã¿
"apple"
"ringo"
âcashewnutsâ
ã
æ ŒçŽããŠããã¡ã¢ãªé åã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽããŠãã
ãã€ã³ã¿å€æ°ãšãªã£ãŠããããšãããããŸããã
ãã€ã³ã¿å€æ°
hairetu[0]
hairetu[1]
hairetu[2]
ã®æ ŒçŽããŠããã¢ãã¬ã¹ã¯
printf("%p\n",hairetu[0]);
printf("%p\n",hairetu[1]);
printf("%p\n",hairetu[2]);
ãè¡ãããããšã«ãã
EAZY IDECã®å Žå
0019FF37
0019FF42
0019FF4D
Visual Studioã®å Žå
003FF8C8
003FF8D3
003FF8DE
ãšè¡šç€ºãããŠããŸã
ã€ãŸã
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ãè¡ãããŠ
é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ãäœè£œãããŠããã®ã§ãã
Visual Studioã®å Žåãªã
é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ã®ã¢ãã¬ã¹ã¯
é åå€æ°
hairetu[0][0]ãªã003FF8C8 ðhairetu[0]ã®ã¢ãã¬ã¹ã§ãã
hairetu[0][1]ãªã003FF8C9
hairetu[0][2]ãªã003FF8CA
hairetu[0][3]ãªã003FF8CB
hairetu[0][4]ãªã003FF8CC
hairetu[0][5]ãªã003FF8CD
hairetu[0][6]ãªã003FF8CE
hairetu[0][7]ãªã003FF8CF
hairetu[0][8]ãªã003FF8D0
hairetu[0][9]ãªã003FF8D1
hairetu[0][10]ãªã003FF8D2
hairetu[1][0]ãªã003FF8D3 ðhairetu[1]ã®ã¢ãã¬ã¹ã§ãã
hairetu[1][1]ãªã003FF8D4
hairetu[1][2]ãªã003FF8D5
hairetu[1][3]ãªã003FF8D6
hairetu[1][4]ãªã003FF8D7
hairetu[1][5]ãªã003FF8D8
hairetu[1][6]ãªã003FF8D9
hairetu[1][7]ãªã003FF8DA
hairetu[1][8]ãªã003FF8DB
hairetu[1][9]ãªã003FF8DC
hairetu[1][10]ãªã003FF8DD
hairetu[2][0]ãªã003FF8DEðhairetu[2]ã®ã¢ãã¬ã¹ã§ãã
hairetu[2][1]ãªã003FF8DF
hairetu[2][2]ãªã003FF8E0
hairetu[2][3]ãªã003FF8E1
hairetu[2][4]ãªã003FF8E2
hairetu[2][5]ãªã003FF8E3
hairetu[2][6]ãªã003FF8E4
hairetu[2][7]ãªã003FF8E5
hairetu[2][8]ãªã003FF8E6
hairetu[2][9]ãªã003FF8E7
hairetu[2][10]ãªã003FF8E8
ãšãªã£ãŠããããã§ãã
ãšããã§
char hairetu[11];
ã«ãã£ãŠäœè£œãããé åå€æ°ã¯
hairetu[0]
hairetu[1]
hairetu[2]
hairetu[3]
hairetu[4]
hairetu[5]
hairetu[6]
hairetu[7]
hairetu[8]
hairetu[9]
hairetu[10]
ã§ããã
ãã®ãšãã®
é åhairetuã®å é ã®ã¡ã¢ãªã®ã¢ãã¬ã¹ãæ ŒçŽããŠãããã€ã³ã¿å€æ°ã¯
hairetuã§ããã
ãã®ãã€ã³ã¿å€æ°hairetuã
printf("%s\n", hairetu);
ã®ããã«çšããããšã§
é åhairetuã«æ ŒçŽãããŠããæååããŒã¿ã®æååã
ã³ãã³ãããã³ããç»é¢ã«printfåºå衚瀺ããããšãã§ããŸããã
次ã«
char hairetu[3][11]={"apple","ringo","cashewnuts"};
ã«ãã£ãŠäœè£œãããé åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
hairetu[1][0]
hairetu[1][1]
hairetu[1][2]
hairetu[1][3]
hairetu[1][4]
hairetu[1][5]
hairetu[1][6]
hairetu[1][7]
hairetu[1][8]
hairetu[1][9]
hairetu[1][10]
hairetu[2][0]
hairetu[2][1]
hairetu[2][2]
hairetu[2][3]
hairetu[2][4]
hairetu[2][5]
hairetu[2][6]
hairetu[2][7]
hairetu[2][8]
hairetu[2][9]
hairetu[2][10]
ããã芳å¯ããŠã¿ããš
ãã®äžã®é åå€æ°
hairetu[0][0]
hairetu[0][1]
hairetu[0][2]
hairetu[0][3]
hairetu[0][4]
hairetu[0][5]
hairetu[0][6]
hairetu[0][7]
hairetu[0][8]
hairetu[0][9]
hairetu[0][10]
ã®
å é ã®é åå€æ°hairetu[0][0]ã®ã¢ãã¬ã¹ãæ ŒçŽããŠãããã€ã³ã¿å€æ°ã¯
hairetu[0]ã§ããã
ãã®ãã€ã³ã¿å€æ°hairetu[0]ã
printf("%s\n", hairetu[0]);
ã®ããã«çšããããšã§
é åhairetuã«æ ŒçŽãããŠããæååã
printfåºå衚瀺ããããšãã§ããŸãããã
printf("%s\n", hairetu[0]);
ã ããã¿ããªã
é åhairetuã®ã¢ãã¬ã¹ãæ ŒçŽããŠãããã€ã³ã¿å€æ°ã
hairetuã ã£ãããã«
ãªãã ããŸãã§
ããããããããhairetu[0]ãšããé åãååšã
ããªãã¡
hairetu[0]ãšããååã®é åhairetu[0]ãçšæãããŠããŠ
é åhairetu[0]ã®ã¢ãã¬ã¹ãæ ŒçŽããŠãããã€ã³ã¿å€æ°ã
hairetu[0]ãšãªã£ãŠããããã«ã¿ããããã
æ°èŠç»é²ã§å å®ã®èªæžã
- ãã€ããŒãž
- èªæžã®ç¶æ³ããäœåãèªåã§åé¡ããŠç°¡åã«ç®¡çã§ãã
- å°èª¬ã®æªèªè©±æ°ãã²ãšç®ã§ãããååã®ç¶ãããèªãã
- ãã©ããŒãããŠãŒã¶ãŒã®æŽ»åãè¿œãã
- éç¥
- å°èª¬ã®æŽæ°ãäœè ã®æ°äœã®æ å ±ãåãåãã
- é²èŠ§å±¥æŽ
- 以åèªãã å°èª¬ãäžèŠ§ã§èŠã€ãããã
ã¢ã«ãŠã³ãããæã¡ã®æ¹ã¯ãã°ã€ã³
ãã¥ãŒã¯ãŒèšå®
æåãµã€ãº
èæ¯è²
ãã©ã³ã
çµã¿æ¹å
æ©èœããªã³ã«ãããšãç»é¢ã®äžéšãã¿ãããã床ã«èªåçã«ã¹ã¯ããŒã«ããŠèªã¿é²ããããŸãã
å¿æŽãããšå¿æŽã³ã¡ã³ããæžããŸã