倩åœã«ãããèšèªå ¥éããããµæ§é äœ verïŒ.2130
ðèªäœé¢æ°2 å€æ°xãåŒæ°ã«ãã€èªäœé¢æ°void fanction(int x)ã«ã€ããŠèå¯ããŠã¿ããint xãxãšèšè¿°ããŠãããã®ã§ããããïŒãã®å Žåãæã£ãéãããã°ã©ã ãå®è¡ã§ããªããªããŸãã
ðèªäœé¢æ°2 å€æ°xãåŒæ°ã«ãã€èªäœé¢æ°void fanction(int x)ã«ã€ããŠèå¯ããŠã¿ããint xãxãšèšè¿°ããŠãããã®ã§ããããïŒãã®å Žåãæã£ãéãããã°ã©ã ãå®è¡ã§ããªããªããŸãã
ããã§ã¯
èªäœé¢æ°ã®å®çŸ©ã®ãããã¯{}å ã«
printf("%d\n",x);
ã®ããã«
åŒæ°ã«å€æ°xã䜿ãããŠããé¢æ°ãããå Žå
ã©ã®ããã«èªäœé¢æ°ã®å®çŸ©ãèšè¿°ããã°ããã§ããããïŒ
次ã®ããã°ã©ã ãã¿ãŠãããŸãããã
#include <stdio.h>
void function(int x){
printf("%d\n",x);
return;
}
int main(void){
function(1);
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
1
ããã§
void function(int x){
ãprintf("%d\n",x);
return;
}
ã§å®çŸ©ãããèªäœé¢æ°function(int x)ã¯
mainé¢æ°ïŒmainãå®ã¯é¢æ°ã§ãïŒå ã§
function(1);
ã®ããã«å®è¡ããŸã
function(1);
ãå®è¡ããããš
()å ã®
intïœã«ä»£å ¥ãããæŽæ°å€1ã
printf("%d\n",x);
ã®
xã«ä»£å ¥ããã
printf("%d\n",1);
ãå®è¡ãããããšã«ãªããŸã
function(5);
ãå®è¡ããããš
()å ã®
intïœã«ä»£å ¥ãããæŽæ°å€5ã
printf("%d\n",x);
ã®
xã«ä»£å ¥ããã
printf("%d\n",5);
ãå®è¡ãããããšã«ãªããŸã
èªäœé¢æ°function(int x)ã¯
function(1);
ã®ããã«()å ã®
intïœã«ä»£å ¥ãããæŽæ°å€ã
printf("%d\n",x);
ãéããŠ
ã³ãã³ãããã³ããç»é¢ã«printfåºå衚瀺ããèªäœé¢æ°ã§ãã
ããã§ã¯ã
ãã®ããã°ã©ã ã«ãããŠ
èªäœé¢æ°
void function(int x){
ãprintf("%d\n",x);
return;
}
ã®intïœã«ä»£å ¥ãããæ°å€ã¯
ã©ãããåããšã£ãŠããã®ã§ããããã
ããã¯
mainé¢æ°å ã§
function(1);
ãšèšè¿°ããããšãã®1ã
intïœã¯åãåã£ãŠããŸãã
function(1);
ãšèšè¿°ããã°
intïœ=1;
ã«çžåœãããã®ãå®è¡ãããããã§ããã
ãã®ãããªããã§
function(1);
ãå®è¡ããããš
printf("%d\n",x);
ã®å€æ°xã«1ãä»£å ¥ããããã®ãå®è¡ãããããšã«ãªã
ããã°ã©ã ã®å®è¡çµæã«
1
ã衚瀺ãããããšã«ãªããŸãã
ãïœãšã»ã»ã»ïŒ
èªäœé¢æ°
void function(int x){
ãprintf("%d\n",x);
return;
}
ã®åŒæ°éšåã®()å ã®
int xã®ä»£ããã«xãèšå®ããŠãããã®ïŒ
ã§ããïŒ
ããã§ã¯
function(ãã)ã®(ãã)ã®äžèº«ã
int xã§ãªãïœãšãã
次ã®ããã°ã©ã ãå®è¡ããŠã¿ãŸãããã
ð
#include <stdio.h>
void function(x){
printf("%d\n",x);
return;
}
int main(void){
function(1);
return 0;
}
ã¡ãã£ãšãŸã£ãŠ
å®ã¯ããã®ãœãŒã¹ã³ãŒãã®èšè¿°ã¯æ£ãããããŸããã
ãªããªã
å€æ°å®£èšint x;ããããªãããŠããªãã®ã«(å€æ°xãçæãããŠããªãã®ã«ïŒ
å€æ°xã䜿ãããšããŠããã®ãšåãããšã ããã§ãã
ãšããããããã°ã©ã ãå®è¡ããŠã¿ããš
ð
#include <stdio.h>
void function(x){
printf("%d\n",x);
return;
}
int main(void){
function(1);
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
EAZY IDECã®å Žå
1
ãšãªããŸãã
Visual Studioã®å Žåã¯
ãšã©ãŒ C2182 'function': 'void' åãäžé©åã«äœ¿çšãããŠããŸãã
ãšã©ãŒ C2448 'function': é¢æ°ã®å®çŸ©ãééã£ãŠããŸãã
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ãšã©ãŒ C2064 1 åŒæ°ãåã蟌ãé¢æ°ã«ã¯è©äŸ¡ãããŸããã
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ã衚瀺ãã
ããã°ã©ã ã®å®è¡ã¯ã§ããŸããã
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ã衚瀺ãããšããããã
Visual Studioã¯xãå€æ°å®£èšãããŠããªããšæ°ä»ããŠããŸãã
æ®éã¯xã®å€æ°å®£èšã®ãªãããã°ã©ã ã§
xãçšãããš
次ã®ããã°ã©ã ã®ããã«
ð
#include <stdio.h>
int main(void){
printf("%d\n",x);//ðxã®å€æ°å®£èšãªãã§ããããªãå€æ°ãçšããããšããŠããŸã
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
ïŒEAZY IDECã®å ŽåïŒ
ãã¡ã€ã«ãC:/Users/solarplexuss/AppData/Local/EasyIDEC/project/ wwww/main.cãã®
ã5è¡ç®ãã§èšè¿°ãšã©ãŒãçºèŠããŸããã
ãxããå®çŸ©ãããŠããŸããã
ååãééã£ãŠããªããã©ãã確èªããŠãã ããã
ããã°ã©ã ã®å®è¡çµæïŒVisual Studioã®å ŽåïŒ
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ð
ãšã©ãŒ(ãã«ããšã©ãŒïŒã衚瀺ãããã®ã§ãã
å ã»ã©ã®ããã°ã©ã ã®å®è¡ã«ãããŠã¯
ð
#include <stdio.h>
void function(x){
printf("%d\n",x);
return;
}
int main(void){
function(1);
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
EAZY IDECã®å Žå
1
ð
ãªãããçµ±åéçºç°å¢EAZY IDECã§ã¯
ããã°ã©ã ã®å®è¡ãã§ããŠããŸã
çµ±åéçºç°å¢EAZY IDECãã€ãã£ãŠãããš
ãã®ããã«
ð
void function(int x){
printf("%d\n",x);
return;
}
ð
èªäœé¢æ° function( ïŒã®äžèº«ãint xã«ãã
xãšããŠ
次ã®ããã«
ð
void function(x){
printf("%d\n",x);
return;
}
ð
èªäœé¢æ°ãå®çŸ©ããŠãããã°ã©ã ã¯å®è¡ã§ããŠããã®ã§
èªäœé¢æ° function( ïŒã®äžèº«ã¯
int xã§ãªãxã§ãããããã«ãããããŸãã
ãã»ã»ã»ã»ã»ã»ã»ã»
ããã§ãããã«ãããã¡ãã£ãšéãã§ã¿ãŸãããã
function(ãã)ã®(ãã)ã®äžèº«ã
int xã§ãªãfloatïœãšãã次ã®ããã°ã©ã ã¯
å®è¡ãããš ã©ã®ãããªçµæã«ãªãã§ããããïŒ
ã«ã³ã«ã³ðæ°åã§å®è¡ããŠã¿ãŸãããã
#include <stdio.h>
void function(float x){
printf("%d\n",x);/*%fåºåå€ææå®åãçšãããšããã ãããŠ%dåºåå€ææå®åãçšããããŠããŸã*/
return;
}
int main(void){
function(1);
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
(EAZY IDECã®å ŽåïŒ
(Visual Studioã®å ŽåïŒ
1
ãšãªããŸãã
ããŸã
1ã衚瀺ãã
ããã°ã©ã ãå®è¡ã§ããŠããããã«èŠããŸãã
ããã§ã¯ãããŸãã
ãã®ããã°ã©ã ã®èšè¿°ã¯æ£ãããããŸãã
ãŸã
function(1)ã®1ã¯
float xã«æ ŒçŽãããããã§ãã
ããã§æŽæ°å€ïŒã¯åå€æã«ããå®æ°ãšããŠfloatåã«æ ŒçŽããªããããŸã
ã€ãŸã
floatåã®å€æ°xã«ã¯å®æ°å€ãšããŠã®1ãæ ŒçŽãããŠãããšããããã§ã
ãã®ç¶æ ã§
ä»ã®èªäœé¢æ°functionã®å®çŸ©
ð
void function(float x){
printf("%d\n",x);
return;
}
ð
ã®
printf("%d\n",x);
ãå®è¡ãããããã§ãã
å®ã¯%dåºåå€ææå®åã§ã¯
floatåã®å€æ°xã«æ ŒçŽãããŠããæ°å€ããŒã¿ã
ããŸãåºå衚瀺ããããšã¯ã§ããŸãã
ããŸããŸ
1
ã衚瀺ãããŠããã®ã§
printf("%d\n",x);
ã§ãããã®ã§ã¯ãªãã
ãšæãããŸãã
ééã£ãŠããŸã
ä»ã®èªäœé¢æ°functionã®å®çŸ©
ð
void fanction(float x){
printf("%d\n",x);
return;
}
ð
ã®
printf("%d\n",x);
ã®èšè¿°ã¯æ£ãããããŸãã
printf("%d\n",x);
ã¯
å®æ°å€ãprintfåºå衚瀺ãããšãã«çšãããã
%fåºåå€ææå®åããã¡ããŠ
printf("%f\n",x);
ã®ããã«æžãæããå¿ èŠããããŸã
printf("%f\n",x);
ãšæžãæããŠ
ããã°ã©ã ãå®è¡ãããš
ããã°ã©ã ã®å®è¡çµæã¯
1.000000
ã«ãªããŸãã
ããã§äººæ ãšããŠ
èªäœé¢æ°functionã®å®çŸ©ã§ function(ã)ã®(ã)ã®äžèº«ã§ãã
èªäœé¢æ°functionã®åŒæ°ã
次ã®ããã«xã§int x ã§ãªãå Žå
ð
void function(x){
printf("%d\n",x);
return;
}
ð
mainé¢æ°å ã§
èªäœé¢æ°functionã®åŒæ°ã§ããxã«
å®æ°5.55ã
ä»£å ¥ãã
function(5.55);
ã
å®è¡ããããš
ã©ã®ãããªå€ã
printf("%d\n",x);
ã«ãã
åºå衚瀺ãããã
è©ŠããŠã¿ãããªããŸããã
ããã°ã©ã ã®å®è¡çµæã¯ã©ããªãïŒã§ããããïŒ
ïŒãè©Šãããã®ïŒïŒ
#include <stdio.h>
void function(x){
printf("%d\n",x);
return;
}
int main(void){
function(5.55);
return 0;
}
(EAZY IDECã®å ŽåïŒ
ããã°ã©ã ã®å®è¡çµæã¯
858993459ãšãªããŸãã
å®æ°ã§ãã5.55ã
æŽæ°å€ãæ±ã%dåºåå€ææå®åãã€ãã£ãŠprintfåºå衚瀺ããããã
5.55ãšãŸã£ããã¡ããæ°å€858993459ãåºå衚瀺ãããŠããŸãã
Visual Studioã®å Žå
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãšã©ãŒ C2064 1 åŒæ°ãåã蟌ãé¢æ°ã«ã¯è©äŸ¡ãããŸããã
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ãšã©ãŒ C2448 'fanction': é¢æ°ã®å®çŸ©ãééã£ãŠããŸãã
ãšã©ãŒ C2182 'fanction': 'void' åãäžé©åã«äœ¿çšãããŠããŸãã
ãšãã«ããšã©ãŒã衚瀺ãããŸãã
ãã¯ãVisual Studioã¯xãå€æ°å®£èšãããŠããªãã®ãæ°ã«ãªã£ãŠããŸãã
ããã§
ããã®ããã°ã©ã ã®èªäœé¢æ°functionã®å®çŸ©å ã®
printf("%d\n",x);ã®éšåã®
%dåºåå€ææå®åã%fåºåå€ææå®åã«å€æããŠ
ããã°ã©ã ãå®è¡ããŠã¿ããš
ïŒãè©Šãããã®ïŒïŒ
#include <stdio.h>
void function(x){
printf("%f\n",x);
return;
}
int main(void){
function(5.55);
return 0;
}
ããã°ã©ã ã®å®è¡çµæã¯
(EAZY IDECã®å ŽåïŒ
5.550000
ãšãªãã¯ãã§ã
ãµã€ãã«ãããããŠããã§ãããã
Visual Studioã®å Žåã¯å®è¡ã§ããŸãã
ãšããã
ããã°ã©ã ã®å®è¡çµæã¯
0.000000ãšãªããŸãã
Visual Studioã®å Žå
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãšã©ãŒ (ã¢ã¯ãã£ã) E0020 èå¥å "x" ãå®çŸ©ãããŠããŸãã
ãšã©ãŒ C2064 1 åŒæ°ãåã蟌ãé¢æ°ã«ã¯è©äŸ¡ãããŸããã
ãšã©ãŒ C2065 'x': å®çŸ©ãããŠããªãèå¥åã§ãã
ãšã©ãŒ C2448 'fanction': é¢æ°ã®å®çŸ©ãééã£ãŠããŸãã
ãšã©ãŒ C2182 'fanction': 'void' åãäžé©åã«äœ¿çšãããŠããŸãã
ãšãã«ããšã©ãŒã衚瀺ãããŸãã
å®æ°å€5.55ã%fåºåå€ææå®åãçšããŠ
printfåºå衚瀺ããã«ãããããã
ãŸãã§æŽæ°ã%fåºåå€ææå®åãçšããŠ
printfåºå衚瀺ãããã®ããã«
0.000000ãã³ãã³ãããã³ããç»é¢ã«è¡šç€ºãããŸããã
ããã¯ãã£ããã©ãããããšã§ããããïŒ
ãã£ããæ°å€5.55ã¯
æŽæ°ã®åã«æ ŒçŽãããŠããã®ãïŒ
å®æ°ã®åã«æ ŒçŽãããŠããã®ãïŒ
ïŒãè©Šãããã®ïŒïŒã®ããã°ã©ã ã®å®è¡çµæ
858993459
ãã¿ããš
æ°å€5.55ã¯å®æ°ã®åã«æ ŒçŽãããŠããã®ã«
%dåºåå€ææå®åãçšããŠprintfåºå衚瀺ããŠãããã
858993459ã衚瀺ããããšãããšã©ãŒã衚瀺ãããŠããããã«ã¿ã
ïŒãè©Šãããã®ïŒïŒã®ããã°ã©ã ã®å®è¡çµæ
0.000000ãã¿ããš
æ°å€5.55ã¯æŽæ°ã®åã«æ ŒçŽãããŠããã®ã«
%fåºåå€ææå®åãçšããŠprintfåºå衚瀺ããŠãããã
0.000000ã衚瀺ããããšãããšã©ãŒã衚瀺ãããŠããããã«ã¿ããŸãã
ã€ãŸãèªäœé¢æ°functionã®å®çŸ©ã«ãããŠ
次ã®ããã«
ð
void function(x){
printf("%f\n",x);
return;
}
ð
void function(int x)ãšèšè¿°ãããšããã
void function(x)ãšèšè¿°ããŠããŸããš
xã«ä»£å ¥ãããæ°å€ã
printf("%f\n",x);
ãã€ãã£ãŠ
ããŸãprintfåºå衚瀺ããããšãã§ããŸãã
ã§ãã®ã§
printf("%d\n",x);
ãã€ãã£ãŠæŽæ°å€ã衚瀺ããããªã
次ã®ããã«
èªäœé¢æ°functionã®å®çŸ©
ð
void function(int x){
printf("%d\n",x); */%dã«ããã®ããããããªã/*
return;
}
ð
å ã®
ãããããããfunction()ã®()ã®äžã«
ããããããxã®intåã®å€æ°å®£èšããint xã
èšè¿°ããå¿ èŠããããŸã
ãŸã
printf("%f\n",x);ãã€ãã£ãŠå®æ°å€ã衚瀺ããããªã
次ã®ããã«
èªäœé¢æ°functionã®å®çŸ©
ð
void function(float x){
printf("%f\n",x); */%fã«ããã®ããããããªã/*
return;
}
ðããããããã
å ã®
ãããããããããfunction()ã®()ã®äžã«
ããããããxã®floatåã®å€æ°å®£èšããfloat xã
èšè¿°ããå¿ èŠããããŸã
ãšãããããšã§æ®éã«
次ã®ããã«
èªäœé¢æ°functionã®å®çŸ©
ð
void function(float x){
printf("%f\n",x); */%fã«ããã®ããããããªã/*
return;
}
ðããããããã
å ã®
ãããããããããfunction()ã®()ã®äžã«
ããããããxã®floatåã®å€æ°å®£èšããfloat xã
èšè¿°ã
printf("%f\n",x);
ã®ããã«
%fåºåå€ææå®åãèšè¿°ããç¶æ ã§
mainé¢æ°ã®ãããã¯{}å ã§
å®æ°5.55ãèªäœé¢æ°functionã®åŒæ°ã®float xã«æ ŒçŽãã
function(5.55);
ãå®è¡ããŠã¿ãŸãð
ãã®ããã°ã©ã ã¯ãã¡ãã§ã
ð
#include <stdio.h>
void function(float x){
printf("%f\n",x);
return;
}
int main(void){
function(5.55);
return 0;
}
ããã°ã©ã ã®å®è¡çµæ
ïŒEAZY IDECã®å ŽåïŒ
ïŒVisual studioã®å ŽåïŒ
5.550000
ãã£ããïŒ
ããŸã
5.550000ãprintfåºå衚瀺ããããšãã§ããŸããð
Visual studioãåŒæ°å ã§float xãã¡ãããšå€æ°å®£èšãããŠããã®ã§
ããã°ã©ã ãå®è¡ããããšãã§ããŠããŸããã
æ°èŠç»é²ã§å å®ã®èªæžã
- ãã€ããŒãž
- èªæžã®ç¶æ³ããäœåãèªåã§åé¡ããŠç°¡åã«ç®¡çã§ãã
- å°èª¬ã®æªèªè©±æ°ãã²ãšç®ã§ãããååã®ç¶ãããèªãã
- ãã©ããŒãããŠãŒã¶ãŒã®æŽ»åãè¿œãã
- éç¥
- å°èª¬ã®æŽæ°ãäœè ã®æ°äœã®æ å ±ãåãåãã
- é²èŠ§å±¥æŽ
- 以åèªãã å°èª¬ãäžèŠ§ã§èŠã€ãããã
ã¢ã«ãŠã³ãããæã¡ã®æ¹ã¯ãã°ã€ã³
ãã¥ãŒã¯ãŒèšå®
æåãµã€ãº
èæ¯è²
ãã©ã³ã
çµã¿æ¹å
æ©èœããªã³ã«ãããšãç»é¢ã®äžéšãã¿ãããã床ã«èªåçã«ã¹ã¯ããŒã«ããŠèªã¿é²ããããŸãã
å¿æŽãããšå¿æŽã³ã¡ã³ããæžããŸã