倩åœã«ãããèšèªå ¥éããããµæ§é äœ verïŒ.2130
ðððåç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒãšã¯èªäœé¢æ°ã®åŒæ°ã«ãã€ã³ã¿å€æ°ãã€ããå®åŒæ°ã®ã¢ãã¬ã¹ããã€ã³ã¿å€æ°ã«æž¡ãæ¹æ³ã®ããšãªã®ã§ãððð
åç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒã®å ·äœäŸã¯mainé¢æ°å ã§å®çŸ©ãããå€æ°aã®ã¢ãã¬ã¹ãèªäœé¢æ°å ã§å®çŸ©ããããã€ã³ã¿å€æ°ptxã«ä»£å ¥ããããšã§ãã
ðððåç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒãšã¯èªäœé¢æ°ã®åŒæ°ã«ãã€ã³ã¿å€æ°ãã€ããå®åŒæ°ã®ã¢ãã¬ã¹ããã€ã³ã¿å€æ°ã«æž¡ãæ¹æ³ã®ããšãªã®ã§ãððð
ãœãŒã©ãŒãé¢çœãä»çµã¿ã«ãªã£ãŠãããã
ãªãã§ãã®ãããªä»çµã¿ã«ãªã£ãŠããã®ãïŒ
ð
次ã®ãããªèªäœé¢æ°fããããšããŸã
ãvoid f(int x){
x=x+1;
}
ð
ãã®ããã«
èªäœé¢æ°fã®åŒæ°éšåã®()å ã§å€æ°å®£èšint xãèšè¿°ãããŠãããšããŸã
ãã®int xã«
mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aãä»£å ¥ããŠ
èªäœé¢æ°
f(a);
ãå®è¡ãããšããŸã
ãã®ãšã
äžèŠãããš
èªäœé¢æ°fã®åŒæ°éšåã®()å ã§å€æ°å®£èšãããå€æ°xã«
mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aãä»£å ¥ããã®ã§
a=a+1;
ãå®è¡ãã
å€æ°aã«æ ŒçŽãããŠããå€ã¯èªäœé¢æ°fã«ããæäœãå ããã
1å¢å ããããã«ã¿ããŸã
ã,ããã
å®éã«ã¯
mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aã«æ ŒçŽãããŠããå€ã«ã¯å€æŽãå ããããŸãã
ð
以åã®ãšããœãŒãã§ãèŠãŠããããã«
ãã®ããšã¯ã¡ã¢ãªã«ããŒã¿ãèãããããšãã芳ç¹ããã¿ãã°
ãšãŠãèªç¶ãªããšã ã£ããã
ïŒããã¯å€æž¡ããšåŒã°ããå€æ°aããå€æ°xãžã®
æ°å€ããŒã¿ã®åãæž¡ãæ¹æ³ã§ãããðïŒ
ãã®ããã«
èªäœé¢æ°fã®åŒæ°éšåã®()å ã«èšè¿°ãããint xã«
mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aãä»£å ¥ããŠ
èªäœé¢æ°fãå®è¡ããŠã(aã«èªäœé¢æ°fã®æäœãå ããã®ãç®çã ã£ãã®ã§ãã)
mainé¢æ°å ã§å®çŸ©ãããå€æ°aã®æ ŒçŽããŠããå€ãå€æŽã§ããªããšãªããš
èªäœé¢æ°fãã€ãã£ãŠãããŸã䜿ãéããªããããããªããã
ãã®ããšã¯
RPGã²ãŒã ã§ããã°
ããã²ãŒã ãã£ã©ã¯ã¿ãŒã®HPãèªäœé¢æ°ã«ãããŠã
HPã®éã¯ãå šãå€åããªããšããããšã«ãªããŸã
ã·ã¥ãŒãã£ã³ã°ã²ãŒã ã§ããã°
ããäœçœ®ã«ãã匟ãå¥ã®äœçœ®ã«ç§»åãããããšããŠèªäœé¢æ°ã«ãããŠã
匟ã®äœçœ®ã¯ãå šã移åããªããšããããšã«ãªããŸã
ããããããããããããããããããããsolarplexussãã
ããããããããããããããããããããã
ãœãŒã©ãŒ
ãããã ã
èªäœé¢æ°å ã§å®çŸ©ãããå€æ°xã«
mainé¢æ°å ã§å®çŸ©ãããå€æ°aãä»£å ¥ããŠèªäœé¢æ°ã«ããæäœãå ããŠã
mainé¢æ°å ã§å®çŸ©ããããããšã®å€æ°aã«æ ŒçŽãããŠããå€ã«å€æŽãå ããããšã¯ã§ããªãã
ãã®ã·ã¹ãã ã¯ã©ããªã£ãŠãã®ãð
ããïŒåºŠ
確ãããŠã¿ããããã¢ã¬ãµã
ã¢ã¬ãµãã¯ãã£
次ã®ããã°ã©ã ã芳å¯ããŠã¿ãŸã
#include <stdio.h>
void newmadefunction(int x)
{
x=x+5;
printf("%d\n",x);
}
int main(void){
int a=1;
newmadefunction(a);/*ããã§èªäœé¢æ°newmadefunctionã«å€æ°aãä»£å ¥*/
printf("%d\n",a);
return 0;
}
ã³ã³ãã€ã«çµæ
EAZY IDECã®å Žå
6
1
Visual Studioã®å Žå
6
1
ã¢ã¬ãµãäžèšã®ããã°ã©ã ã§ã¯
å€æ°aã®æã£ãŠããå€1ãå€æ°xãžå€æž¡ããããæ§åã芳å¯ã§ããŸãã
èªäœé¢æ°newmadefunctionã®åŒæ°éšåã®()å ã§
int x
ãš
å€æ°å®£èšãäœè£œãããå€æ°x
ãšããåã®ã€ããã¡ã¢ãªãš
mainé¢æ°å ã§
int a=1;
ãš
å€æ°å®£èšãäœè£œãããå€æ°a
ãšããåã®ã€ããã¡ã¢ãª
ã¯å®å šã«ç¬ç«ããŠããŸã
èªäœé¢æ°
newmadefunction(a);
ãå®è¡ããããšã«ãã
å€æ°x
ãšããåã®ã€ããã¡ã¢ãªã«
ããã
å€æ°a
ãšããåã®ã€ããã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ããŒã¿1ãä»£å ¥ããã®ã¡
x=x+5;
ã«ãã
å€æ°x
ãšããååã®ã€ããã¡ã¢ãªã«æ ŒçŽãããŠããå€ã
1ãã6ã«å€æŽãããšããŠã
å€æ°a
ãšããååã®ã€ããã¡ã¢ãªã«æ ŒçŽãããŠããå€ã¯1ããå€åããªãã®ã§ããã
ãã®ããã«
èªäœé¢æ°newmadefunctionã䜿ã£ãŠ
mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aã«æ ŒçŽãããŠããå€ãå€åãããããšããŠ
ããããããããããnewmadefunction(a);
ãå®è¡ãããŠã
ãå€æ°aãèªäœé¢æ°newmadefunctionã®æäœããããŸãã
ããããããããããããå€æž¡ããšã¯
ãå€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿1ã ã
ã
èªäœé¢æ°ã®åŒæ°xã«æž¡ãããã·ã¹ãã ãªã®ã§ã
ã§ãã®ã§
ããããããããããnewmadefunction(a);
ãå®è¡ãããŠã
ãå€æ°aã¯èªäœé¢æ°newmadefunctionã®æäœãåããããšã¯ãªã
ãå€æ°aã«æ ŒçŽãããŠããæ°å€ã¯ a=1ã®ãŸãŸå€ããã
ãããã°ã©ã å ã®æåŸã®åœä»€æ
ãprintf("%d\n",a);ã®
ãå®è¡çµæãšããŠ
ã1
ãã衚瀺ãããããšã«ãªããŸãã
ãœãŒã©ãŒ
ããã¯ã£ãå€æ°aã®å€ã1ãã6ã«å€åãããããã«èªäœé¢æ°ãã€ãã£ãŠã
ããã§ã¯èªäœé¢æ°äœè£œã®æå³ããªããªããããããð
ããŸã£ãã¡ããã ãªïœ
ã©ãããã£ããªïœïœ
ãã®ãŸãŸã§ã¯
å€æ°aã«æ ŒçŽãããŠããå€ãå€æŽã§ããªãã®ã§
å€æ°aã«æ ŒçŽãããŠããå€ãå€æŽããã«ã¯
èªäœé¢æ°ã䜿ãã
çŽæ¥
mainé¢æ°å ã§å€æ°aã«ãæäœãå ããªããšãããªããªãããª
ãã®ããã°ã©ã ã¯
å ã®ããã°ã©ã ã®èªäœé¢æ°newmadefunctionã®å®çŸ©ãæ¶ã
newmadefunction(a);
ã®éšåã
a=a+5;
printf("%d\n",a);
ã«ããããã
次ã®ããã°ã©ã ã®ããã«ãªãïŒããªïŒ
#include <stdio.h>
int main(void) {
int a = 1;
a = a + 5;
printf("%d\n", a);
return 0;
}
ã³ã³ãã€ã«çµæ
EAZY IDECã®å Žå
6
Visual Studioã®å Žå
6
ããã§äœãšãå€æ°aã«æ ŒçŽãããŠããå€ã
1ãã6ã«ãããŠprintfåºå衚瀺ã§ããŸããð
ãã®ããã«
newmadefuncution(a);
ãå®è¡ããŠã
aã®æ ŒçŽããŠããå€ãå€æŽã§ããªãã®ã§
aã®æ ŒçŽããŠããå€ãå€æŽããããã«ã¯
mainé¢æ°å ã§
a=a+5;
printf("%d\n",a);
ãšèšè¿°ããªããã°ãªããªããªããŸããð
ä»ã®å Žåã¯
a=a+5;
printf("%d\n",a);
ãçãåœä»€æã ã£ãã®ã§
èšè¿°ã¯ç°¡åã§ããã
é·ããŠè€éãªåœä»€æã®ãã€ãŸãã ã£ãã
äœåããã®éšåãæžããªããšãããªãå Žåã¯
ããªãæéãããããããããªããððð
ãããã
ã¢ã¬ãµããããªã® ã§ã
ãã®ãããªçµæã«ãªã£ãŠããã®ã¯
çµå±ã®ãšãã
èªäœé¢æ°newmadefuncutionå ã§
int x
ãš
å€æ°å®£èšãäœè£œãããå€æ°x
ãšããåã®ã€ããã¡ã¢ãªãš
mainé¢æ°å ã§
int a=1;
ãš
å€æ°å®£èšãäœè£œãããå€æ°a
ãšããåã®ã€ããã¡ã¢ãª
ã¯å®å šã«ç¬ç«ããŠãããšããããšãæ ¹æ¬çãªðåå ãªã®ã§ãã
èªäœé¢æ°newmadefuncution(int x)ã®åŒæ°ã§ãã
int xã®éšåã«å€æ°aãä»£å ¥ãã
newmadefuncution(a);
ãèšè¿°ããå Žå
å€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿1ãå€æ°xã«æž¡ãããšã¯ã§ããŸãã®
ãã®ã·ã¹ãã ã
ããããããããããå€æž¡ããšåŒã°ããã·ã¹ãã ãªã®ã§ã
ããããããããããããããããããããããããããããããããããã
ãœãŒã©ãŒãã§ã¯
èªäœé¢æ°ãã€ãã£ãŠ
mainé¢æ°å ã§å€æ°å®£èšããã
å€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽããã·ã¹ãã ã¯ããã®ããªïŒ
ãããããããããããããããããããããã
ããšãã°æ¬¡ã®ãããªã·ã¹ãã ã¯ã©ãããªã»ã»ã»
èªäœé¢æ°newmadefuncutionã®åŒæ°ã§ãã
å€æ°xã«mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aã
newmadefuncution(a);
ãš
èšè¿°ãããš
å€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿1ãå€æ°xã«æž¡ãããšã¯ã§ãããã ã£ãã
å€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿1ãå€æ°xã«æž¡ããã®ã¡
x=x+5;
ãå®è¡åŸ
å€æ°xã«æ ŒçŽãããããšã«ãªã£ã
æ°å€6ã
åã³
å€æ°xãã
å€æ°aã«æ»ããŠä»£å ¥ãããšãïŒ
ããã°ã©ã ãèšè¿°ãããš
#include <stdio.h>
int newmadefunction(int x)/*return x;ã«ããè¿ãããæ»ãå€ãæ ŒçŽããããã«voidããintã«å€æŽããŸããã*/
{
x = x + 5;
printf("%d\n", x);
}
int main(void) {
int a = 1;
newmadefunction(a);/*ããã§èªäœé¢æ°ã«å€æ°aãä»£å ¥*/
printf("%d\n", a);
a = x;/*mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aã«èªäœé¢æ°å ã§
å€æ°å®£èšãããå€æ°xãä»£å ¥ããããšããŠããŸãã*/
printf("%d\n", a);
return 0;
}
ãœãŒã©ãŒãããããã«ãïŒã
ãã«ãå®è¡çµæ
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãœãŒã©ãŒãããðŠãããã
a = x;/*mainé¢æ°å ã§å€æ°å®£èšãããå€æ°aã«èªäœé¢æ°å ã§
å€æ°å®£èšãããå€æ°xãä»£å ¥ããããšããŠããŸãã*/
ãå®è¡ããããšããŠã
xã¯èªäœé¢æ°å ã§äœè£œãããå€æ°ã ãã
mainé¢æ°å ã§äœ¿çšã§ããªãã®ãã»ã»ã»
ãïœããããŸã£ã¡ãã£ããªïœã
ã¢ã¬ãµ
ãã¯ãã£
å€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽãã
äŸãã°
å€æ°aã«æ ŒçŽãããŠããæ°å€ã«1ãå ããããªã
a=a+1;
ããããªãã°ããããšã«ãªããŸãã
ãœãŒã©ãŒãã¯ã²ïŒã
ã¢ã¬ãµ
ãã¯ãã£ð
å€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽãã
äŸãã°
å€æ°aã«æ ŒçŽãããŠããæ°å€ã«1ãå ããããªã
çŽæ¥
å€æ°aããã¡ããŠ
a=a+1;
ããããªãã°ããããšã«ãªããŸãã®
ã€ãŸã
ãšãŠãåçŽãªããšã§
ããããã
ããããðå€æ°aãšååã®ä»ããã¡ã¢ãªã«çŽæ¥ã¢ã¯ã»ã¹ããŠð
ããããããðæ ŒçŽãããŠããããŒã¿ããããããã°ããð
ãšããããšã«ãªããã§ãã®ãã
solarplexusssããªã«ãã
ã¢ã¬ãµããŸãã¯
ãããããðå€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽããð
ã«ã¯
ãããããããðå€æ°aãšããååã®ã€ããããã¡ã¢ãªð
ã«æ ŒçŽãããŠããæ°å€ããŒã¿ã
ããããããããããðå€æ°aãã€ãã£ãŠð
å€æŽããŠããã°ãããšãããããªãã§ãã®ã
ãœãŒã©ãŒãããããã»ã»ã»
ãŸãã«ããããã°
å€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽããããšã¯ã§ãããã ãã©ã»ã»ã»ã
ã¢ã¬ãµãäŸãã°
å€æ°aã«æ ŒçŽãããŠããæ°å€ã«100ãå ããããªã
a=a+100;
ããããªãã°
å€æ°aãšããååã®ã€ããããã¡ã¢ãª
ã«æ ŒçŽãããŠããæ°å€ããŒã¿ã«100ãå ããããšãã§ããŸããã
solarplexuss
ãããã¯ãšãŠãæ®éã§èªç¶ãªã»ã»ã»ã
ãœãŒã©ãŒããŸãããã®ãšããã ããã
ã¢ã¬ãµãèªäœé¢æ°ã®åŒæ°éšåã®()å ã§
int x
ãš
å€æ°å®£èšãäœè£œãããå€æ°x
ãšããåã®ã€ããã¡ã¢ãªãš
mainé¢æ°å ã§
int a=1;
ãš
å€æ°å®£èšãäœè£œãããå€æ°a
ãšããåã®ã€ããã¡ã¢ãª
ã¯å®å šã«ç¬ç«ããŠãã以äž
ã©ã®ãããªå€ã
å€æ°xã«æ ŒçŽããŠã
å€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿ã«å€åãèµ·ããããšã¯ãããŸããã
ã§ãã®ã§
å€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿ãå€æŽããã®ã«
èªäœé¢æ°å ã§
int x
ãš
å€æ°å®£èšãå€æ°x
ãšããåã®ã€ããã¡ã¢ãªãäœè£œããããšã¯
æå³ããªãããšã«ãªãã®ã§ãã®ãã
solarplexussããããã»ããšã ã
ã¢ã¬ãµããšããããšã¯
èªäœé¢æ°å ã§
int x
ãš
å€æ°å®£èšãå€æ°x
ãšããåã®ã€ããã¡ã¢ãªãäœè£œããããšã¯ãã
æåãã
èªäœé¢æ°å ã§ã
mainé¢æ°å ã§
int a=1;
ãš
å€æ°å®£èšãäœè£œãããå€æ°a
ãšããåã®ã€ããã¡ã¢ãª
ã«ã¢ã¯ã»ã¹ããŠ
å€æ°aã«æ ŒçŽãããŠããæ°å€ã
çŽæ¥
å€æŽããã°ãããšããããšã«ãªããŸããã
ãœãŒã©ãŒãããã»ã»ã»ã
solarplexussããããðã
ã¢ã¬ãµãããã¯
ãã§ã«åŠãã§ãããã€ã³ã¿å€æ°ã
èªäœé¢æ°ã®å®çŸ©ã«ã€ããã°å¯èœã«ãªããã§ãã®
ããã€ã³ã¿å€æ°ãèªäœé¢æ°ã®å®çŸ©ã«çšããã·ã¹ãã ã§ã¯ãããããã
ãå€æ°aã®ã¢ãã¬ã¹ãèªäœé¢æ°ã®åŒæ°ã«æž¡ããšããæ¹åŒããšã£ãŠãããã
èªäœé¢æ°ã®åŒæ°ã«ã¯
å€æ°xã§ãªã
å€æ°aã®ã¢ãã¬ã¹ãæ ŒçŽããããšãã§ãããã€ã³ã¿å€æ°ptx(ä»®ã«ãã€ã³ã¿å€æ°ã®ååãptxãšããŸãã)ãçšããããŸã
ãŸããŸã
å€æ°ã®ã¢ãã¬ã¹ãæ ŒçŽãããã€ã³ã¿å€æ°ãç»å ŽããŠããŸããã
ãœãŒã©ãŒ
ãå€æ°aã®ã¢ãã¬ã¹ãèªäœé¢æ°ã®åŒæ°ã«æž¡ããšããæ¹åŒïŒ
ã©ãããããšïŒ
ã¢ã¬ãµã¡ãããã«ããïœãããã¢ã¬ãµã¡ããðã
solarplexussããããããããðã
ã¢ã¬ãµ
ãã¯ãã£ðã¯ã
ããã§ã¯
ããã§ãã€ã³ã¿å€æ°ã®ãããããããŠã¿ãŸãð
ããããã®æéã®å§ãŸãã§ã
以äžã®ããã°ã©ã ã§ã¯
å€æ°aã®ã¢ãã¬ã¹ã
æ ŒçŽããããã«ptaã®ãã€ã³ã¿å€æ°å®£èšãè¡ã£ãŠããŸã
#include <stdio.h>
int main(void){
int a=1;
int* pta;/*ðptaã®ãã€ã³ã¿å€æ°å®£èšãè¡ããŸãð*/
pta=&a;/*ãã€ã³ã¿å€æ°ptaã«å€æ°aã®ã¢ãã¬ã¹&aãè¡ãæ ŒçŽããŸã*/
printf("å€æ°aã®ã¢ãã¬ã¹ã¯%pã§ãã\n",&a);
printf("ãã€ã³ã¿å€æ°ptaã«æ ŒçŽãããå€æ°aã®ã¢ãã¬ã¹&aã®å€ã¯%pã§ãã\n",pta);
printf("å€æ°aã«æ ŒçŽãããŠããæ°å€ã¯%dã§ãã\n",*pta);
/*ãã®*ptaã®äœ¿ãæ¹ããã€ã³ãã§ãð*/
return 0;
}
ã³ã³ãã€ã«çµæ
å€æ°aã®ã¢ãã¬ã¹ã¯0019FF54ã§ãã
ãã€ã³ã¿å€æ°ptaã«æ ŒçŽãããå€æ°aã®ã¢ãã¬ã¹&aã®å€ã¯0019FF54ã§ãã
å€æ°aã«æ ŒçŽãããŠããæ°å€ã¯1ã§ãã
ãã®ããã°ã©ã ãã芧ã«ãªãããŠããåããã«ãªãããŸãããã«
ãããðããã€ã³ã¿å€æ°ptaã«å€æ°aã®ã¢ãã¬ã¹&aãæ ŒçŽãããŠãð
ãããðããããããããããã¯ãããŠããããããããããããð
ãðã*ptaã¯å€æ°aã«æ ŒçŽãããŠããæ°å€ãããããã®ã§ããããðã
ã
ãããããããããããããããããããããããããããããããããããããããããããããããããããããããããããããããã
ãœãŒã©ãŒããããããããã ã£ã
ãããŠ
int* pta;ã€ã³ãŒã«int *pta;ã㯠ptaã®ãã€ã³ã¿å€æ°å®£èš
*pta 㯠ãã€ã³ã¿ å€æ°ptaãæ ŒçŽããŠããã¢ãã¬ã¹ã®ã¡ã¢ãªã«
æ ŒçŽãããŠããæ°å€
ä»ã®å Žå
ãã€ã³ã¿å€æ°ptaã«å€æ°aã®ã¢ãã¬ã¹&aãæ ŒçŽãããŠããã®ã§
*pta ã¯
å€æ°aãæ ŒçŽããŠããæ°å€
ããããããŠããŸã
ptaã«*ïŒã¢ã¹ã¿ãªã¹ã¯ïŒæŒç®åãäœçšãã*ptaãç»å Žããã®ã¯
ptaã®ãã€ã³ã¿å€æ°å®£èš
int* pta;
ã€ã³ãŒã«
int *pta;
ã®ãšããš
ãã€ã³ã¿ å€æ°ptaãæ ŒçŽããŠããã¢ãã¬ã¹ã®ã¡ã¢ãªã«
æ ŒçŽãããŠããæ°å€ã«ã¢ã¯ã»ã¹ããå Žåã®2éãããããã ã
åã*ïŒã¢ã¹ã¿ãªã¹ã¯ïŒãã€ããŠããŠã
int *pta;
ãš
*pta
ã§ã¯
æå³åããã¡ãã£ãŠããã ã£ãã
ã¢ã¬ãµãããã§ã¯ð
å çšã®å€æž¡ããè¡ãããããã°ã©ã ããã€ã³ã¿å€æ°ãã€ãã£ãŠ
æžãæããŠã¿ãŸã
å çšã®ããã°ã©ã
ð
#include <stdio.h>
void newmadefunction(int x)
{
x=x+5;
printf("%d\n",x);
}
int main(void){
int a=1;
newmadefunction(a);/*ããã§èªäœé¢æ°newmadefunctionã«aãä»£å ¥*/
printf("%d\n",a);
return 0;
}
ã³ã³ãã€ã«çµæ
6
1
ãã
ãã€ã³ã¿å€æ°ãçšããããã°ã©ã
ð
#include <stdio.h>
void newmadefunction(int* ptx)
{
*ptx=*ptx+5;
printf("%d\n",*ptx);
}
int main (void){
int a=1;
newmadefunction(&a);
printf("%d\n",a);
return 0;
}
ã³ã³ãã€ã«çµæ
6
6//ðããã«æ³šç®ãå€æ°ã«æ ŒçŽãããŠããå€ã1ãã6ã«å€åããŠããŸã
ã«å€æŽããŸããã
å€æŽããããã°ã©ã ã§ã¯
å çšã®èªäœé¢æ°ã®å®çŸ©
void newmadefunction(int x){
x=x+5;
printf("%d\n",x);
}
ããã€ã³ã¿å€æ°ptxã䜿ã
ð
èªäœé¢æ°ã®å®çŸ©
void newmadefunction(int* ptx){
*ptx=*ptx+5;
printf("%d\n",*ptx);
}
ã«ãããããŠããŸããã
ãã
ãããããnewmadefunction(int* ptx)ã®int* ptx
ã«ã泚ç®ãã ãã
ãããããããããmainé¢æ°å ã§å€æ°å®£èšããã
ãããããå€æ°aã«æ ŒçŽãããŠããæ°å€ããŒã¿ãå€æŽããããã«ã¯
ããããããããèªäœé¢æ° newmadefunctionã®åŒæ°()ã«
ããããããå€æ°aã®ã¢ãã¬ã¹ãä»£å ¥ããããšãã§ããããã«ããããã«
ãããããããããããããããŸã
ãããããããããããptxã®ãã€ã³ã¿å€æ°å®£èš
ãããããããint* ptxãèªäœé¢æ° newmadefunctionã®åŒæ°()å ã«èšè¿°ããä»çµã¿ãšãªã£ãŠããŸãã
ããããŠãðå€æ°aã®ã¢ãã¬ã¹&aããã€ã³ã¿å€æ°ptxã«ä»£å ¥ããããšð
ããããããããããããããã*ptxã¯
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«ã¢ã¯ã»ã¹ããããšãã§ããããã«ãªã
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ãè¡šãããšã«ãªããŸã
ãããŠ
ãã®*ptxãçšããã°
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«ã¢ã¯ã»ã¹ã
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ã
å€æŽããããšãã§ããŸã
ãã®*ptxãèªäœé¢æ°ã®å®çŸ©ã«çšããããšã«ãã
*ptxãçšããŠå€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«ã¢ã¯ã»ã¹ã
æäœãå ããããšã§
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ãå€æŽ
ã€ãŸã
å€æ°aã®æ ŒçŽããŠããå€ãå€æŽã§ããŸã
ããªãã¡
*ptx=*ptx+5;
ã¯
a=a+5;
ãå®è¡ããããšãšçãããªããã§ãã®
ãœãŒã©ãŒããã
ãœãŒã©ãŒãðã³ãã£ã
ã¢ã¬ãµã
ãã®ããã«
mainé¢æ°å ã§å€æ°å®£èšããã
å€æ°aã«æ ŒçŽãããŠããæ°å€ã
å€æ°aãšããååãä»ããããã¡ã¢ãªã«çŽæ¥ã¢ã¯ã»ã¹ããŠ
å€æŽã§ããããã«
ããããããããå€æ°aã®ã¢ãã¬ã¹&aã
èªäœé¢æ°ã®åŒæ°ãšãªã£ãŠãããã€ã³ã¿å€æ°ã«ä»£å ¥ããããšã
ãããããããããðåç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒð
ãšåŒã³ãŸã
ãããŠ
èªäœé¢æ°ã®åŒæ°ã«mainé¢æ°ã§å®çŸ©ãããå€æ°aã®ã¢ãã¬ã¹&aã
ãããã®ã«
èªäœé¢æ°(ãã€ã³ã¿å€æ°å®£èš);
ãã®å Žåã¯
newmadefunction(int* ptx);
ãšèšè¿°ããã®ã¯Cèšèªã®ããŸããšãªã£ãŠããŸã
ããã§ãã€ã³ã¿å€æ°å®£èšããã
ãã€ã³ã¿å€æ°ptxã«å€æ°aã®ã¢ãã¬ã¹ãä»£å ¥ããããš
*ptxã¯
å€æ°aã«çãããªã
ã€ãŸã
å€æ°aãšããååã®ã€ããã¡ã¢ãªã«çŽæ¥
ã¢ã¯ã»ã¹ããããšãã§ãããã«ãªããŸãã
èªäœé¢æ°ã®å®çŸ©
void newmadefunction(int* ptx){
*ptx=*ptx+5;
printf("%d\n",*ptx);
}
ã¯
å€æ°aãšããååã®ã€ããã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ããŒã¿ã
èªåã®ç®çã«ãã£ãŠå€æŽãããããã«
*ptxãçšããŠ
*ptx=*ptx+5;
ãš
èšè¿°ãããŠããã®ãããããŸãã
ãã®å Žåã¯
å€æ°aãšããååã®ã€ããã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ããŒã¿ã«
5ãå ããããšããŠããã®ã§ããã
*ptx=*ptx+5;
ã¯
a=a+5;
ãå®è¡ãããŠããã®ãš
çããã®ã§ããã
ãœãŒã©ãŒãðåç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒðãšã¯
èªäœé¢æ°ã®åŒæ°ã«å€æ°xãçšã
å€æ°xã«å€æ°aãä»£å ¥ããã®ã§ãªã
èªäœé¢æ°ã®åŒæ°ã«ãã€ã³ã¿å€æ°ptxãçšã
å€æ°aã®ã¢ãã¬ã¹&aããã€ã³ã¿å€æ°ptxã«æž¡ãããšãªãã ãã
ããããã°
*ptxã¯å€æ°aã«çãããªã
*ptxã«æ ŒçŽãããŠããæ°å€ãå€æŽããŠããã°
å€æ°aã«æ ŒçŽãããŠããæ°å€ãå€æŽããããã ã
ããããããã£ãšã¯ã£ããèšãã°
ãããããããðððæåããððð
ãããããããðððèªäœé¢æ°å ã§ãððð
ãããããããðððmainé¢æ°å ã§ãððð
ãããããããðððå€æ°aã®ã¡ã¢ãªã«ããððð
ãðððãã®ããã°ã©ã ã§ã¯ã¢ã¯ã»ã¹ããŠããªããã ããððð
ã
ã¢ã¬ãµããããªãã§ã
ããããã
èªäœé¢æ°newmadefunctionã®å®çŸ©ãèŠãŠãããŸããã
*ptx=*ptx+5;
printf("%d\n",*ptx);
ãã®ããã«
*ptxã«ïŒãå ããããšã«ãã
å€æ°aã«æ ŒçŽãããŠããå€ã«5ãå ããããšãã§ããŸã
ðãðãðãðãðãðãðãðãð
äœè«ã§ãã
*ptxãšæžãããã ãã®
ç¶æ ã§ã¯ãã€ã³ã¿å€æ°ptxã¯ãŸã åæåãããŠããŸãã
ã§ãã®ã§
ãã€ã³ã¿å€æ°ptxã¯åæåãããŠããªããšå éšã«
ãªãã®ã¢ãã¬ã¹ãããããªãã¢ã³ã¹ã¿ãŒã¢ãã¬ã¹ãæ ŒçŽããŠããŸã
ã§ãã®ã§ð
ãã®ãŸãŸã§ã¯ã
*ptxã¯
åæåãããŠããªããã€ã³ã¿å€æ°ptxã
æ ŒçŽããŠããã¢ã³ã¹ã¿ãŒã¢ãã¬ã¹ã®å Žæã®ã¡ã¢ãªã«
æ ŒçŽãããŠããæ°å€ãè¡šããŠããŸããŸã
ãã€ã³ã¿å€æ°ptxã«å€æ°aã®ã¢ãã¬ã¹ã
ptx=&a;ãš
æ ŒçŽãããŠã
ã¯ãããŠ
*ptxã¯å€æ°aã«æ ŒçŽãããŠããæ°å€ãããããããšã«ãªããŸã
ðãðãðãðãðãðãðãðãð
ããããŠ
ãã€ã³ã¿å€æ°ptxã«
ptxïŒ&a;ãš
ãããðððå€æ°aã®ã¢ãã¬ã¹&aãä»£å ¥ããã°ððð
ããããããã
ãããããããð*ptxã¯å€æ°aãšå šãçãããªãð
*ptxã¯å€æ°aãæ ŒçŽããŠããå€1ããã€ããšã«ãªããŸã
å¥ã®èšãæ¹ãããã°
ð*ptxã¯ãã€ã³ã¿å€æ°ptxãæ ŒçŽããŠããã¢ãã¬ã¹ã®å Žæã®ã¡ã¢ãªã«ð
ããããã
ãããããããððæ ŒçŽãããŠããæ°å€ãè¡šãðð
ã®ã§
ãã€ã³ã¿å€æ°txã«
ptxïŒ&a;
ãšå€æ°aã®ã¢ãã¬ã¹&aãä»£å ¥ããã°
*ptxã¯ã¢ãã¬ã¹&aã«æ ŒçŽãããŠããæ°å€1ãè¡šããŸã
*ptxã¯
æ°å€1ãããããããã§ããã
ãã®ãšã
*ptx=*ptx+5;
ã®ãããªæäœã¯
a=a+5;
ãšå šãçãããªããŸãã®ã§
*ptx=*ptx+5;
ãå®è¡ãããããšã«ãã
*ptx=6ãšããå€ããã€ãšããããšã¯
ã¯
a=a+5;
ãå®è¡ãããããšã«ãã
a=6ãšããå€ããã€ãšããããšãš
çãããªããŸãã
å¥ã®èšãæ¹ãããã°
*ptxã¯å€æ°aãšäžç·ã§
ãã€ã³ã¿å€æ°ptxãæ ŒçŽããŠããã¢ãã¬ã¹&aã®å Žæã®ã¡ã¢ãªã«
ã¢ã¯ã»ã¹ããããšãã§ã
ãããã
ãããããðãã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ãè¡šãð
ã®ã§
*ptx=*ptx+5;
ãå®è¡ããããš
*ptx=6
ãšãªã
å€æ°aã®ã¢ãã¬ã¹&aã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ã¯6ã«å€æŽãããŸã
ã€ãŸã
å€æ°aã«æ ŒçŽãããŠããæ°å€ã¯6ã«å€æŽãããã®ã§ã
printf("%d\n",a);ã®
å®è¡çµæã
6ã«ãªã£ãŠããŸãã
ãã®ããã«ããŠ
å€æž¡ãã§ã¯ã§ããªãã£ãã®ã§ãã
èªäœé¢æ°ã®åŒæ°ã§ãããã€ã³ã¿å€æ°ptxã«
å€æ°aã®ã¢ãã¬ã¹&aãæž¡ã
mainé¢æ°å ã§å®çŸ©ãããå€æ°aã«
æ ŒçŽãããŠããæ°å€ã1ãã6ã«å€æŽããããšãã§ããŸãã
ãã€ã³ã¿å€æ°ã«ã¯ãã®ãããªäœ¿ãéããã£ãã®ã§ãããã
ãœãŒã©ãŒããã®ã·ã¹ãã ã¯ãçµæ§ã€ããããã ããã
ã¢ã¬ãµãããã§ãã
èªäœé¢æ°ãã€ãã£ãããã°ã©ã ã§ã¯
mainé¢æ°å ã§äœè£œãããå€æ°aã«æ ŒçŽãããŠããæ°å€ã
å€æŽããå¿ èŠãããå Žåãå€ã
ããããšããã«
ãã®
åç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒãç»å ŽããŠããã®ã§ãã®ã
ãœãŒã©ãŒããã¯ã¯ããðãããããã£ãã
ã¢ã¬ãµã
åç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒãšã¯
ããããããšã ã£ããã ã
ãã€ã³ã¿å€æ°ãèªäœé¢æ°ã®åŒæ°ã«äœ¿ããªãå€æž¡ããš
ãã€ã³ã¿å€æ°ãèªäœé¢æ°ã®åŒæ°ã«äœ¿ãåç §æž¡ããã»ã»ã»
ãããðããã§
åç §æž¡ãïŒãã€ã³ã¿æž¡ãïŒã䜿ã£ãŠ
ã·ã¥ãŒãã£ã³ã°ã²ãŒã ã®åŒŸã®äœçœ®ã
å€æŽã§ããããã«ãªã£ãã£ãŠããšããªïŒã
ã¢ã¬ãµãRPGã«ã§ãŠãããã£ã©ã®ã¹ããŒã¿ã¹
ã®HPãå€æŽããããšãäŸã«èããŠã¿ãŸãã
ããã§
å çšã®ããã°ã©ã ã®
ð
#include <stdio.h>
void newmadefunction(int*ptx)
{
*ptx=*ptx+5;
printf("%d\n",* ptx);
}
int main (void){
int a=1;
newmadefunction(&a);
printf("%d\n",a);
return 0;
}
ã³ã³ãã€ã«çµæ
6
6
èªäœé¢æ°åãnewmadefunctionããHeal
å€æ°åaãHPã«ãããŠã¿ããš
#include <stdio.h>
void Heal(int*ptx)
{
*ptx=*ptx+5;
printf("%d\n",*ptx);
}
int main (void){
int HP=1;
Heal(&HP);
printf("%d\n",HP);
return 0;
}
ã³ã³ãã€ã«çµæ
6
6
ãšãªã
å€æ°HPã®æ ŒçŽããŠããå€ã
èªäœé¢æ°Healã«ãã£ãŠ1ãã6ã«å€æŽãããŠããã®ãããããŸãã
å€æ°HPã®ã¢ãã¬ã¹ã®å Žæã®ã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ã
èªäœé¢æ°Healã«ãã£ãŠ6ã«å€åããããšããããã§ã
ãã®ããšã¯
ãã£ã©ã¯ã¿ãŒã®HPãHealã«ãã£ãŠå埩ããããšã«çžåœããŸãã
ãããã........
ãã¡ã¯ã ããã£ãŠïŒ
ãã¡ã¯ã«ããïœãã§ãã
ããã¯
å€æ°aãšããååã®ä»ããã¡ã¢ãªã«æ ŒçŽãããŠããæ°å€ãå€æŽããã«ã¯
å€æ°aãšããååã®ä»ããã¡ã¢ãªã«ã¢ã¯ã»ã¹ããããæ¹æ³ããªããš
ç解ããŸããã«ããã
ã·ã·
ããããŸãã ã£ãŠïŒã«ãïŒ
ãã¡ããããããã«ãã
ã ãã
ããã«ããããŠããã¹ã£ãŠãã«ãããã
æ°èŠç»é²ã§å å®ã®èªæžã
- ãã€ããŒãž
- èªæžã®ç¶æ³ããäœåãèªåã§åé¡ããŠç°¡åã«ç®¡çã§ãã
- å°èª¬ã®æªèªè©±æ°ãã²ãšç®ã§ãããååã®ç¶ãããèªãã
- ãã©ããŒãããŠãŒã¶ãŒã®æŽ»åãè¿œãã
- éç¥
- å°èª¬ã®æŽæ°ãäœè ã®æ°äœã®æ å ±ãåãåãã
- é²èŠ§å±¥æŽ
- 以åèªãã å°èª¬ãäžèŠ§ã§èŠã€ãããã
ã¢ã«ãŠã³ãããæã¡ã®æ¹ã¯ãã°ã€ã³
ãã¥ãŒã¯ãŒèšå®
æåãµã€ãº
èæ¯è²
ãã©ã³ã
çµã¿æ¹å
æ©èœããªã³ã«ãããšãç»é¢ã®äžéšãã¿ãããã床ã«èªåçã«ã¹ã¯ããŒã«ããŠèªã¿é²ããããŸãã
å¿æŽãããšå¿æŽã³ã¡ã³ããæžããŸã