C言語 戻り値をもたない関数voidを使った課題
Posted: 2021年11月22日(月) 21:28
「大文字のアルファベットを入力すると、その文字を10文字表示するプログラムを作成せよ。」
といった課題で、以下のプログラムを作ってみたのですが、上手くいかず躓いているのでお助けいただけるとありがたいです。
#include <stdio.h>
void A(int);
int main(void){
int m;
printf("Capital Letter: ");
scanf("%d",&m);
A(10);
return 0;
}
void A(int n){
int i;
for(i=1;i<=n;i++)printf("%d",m);
puts("");
}
以下のエラーコードが出ます。
21: error: `m' undeclared (first use in this function)
21: error: (Each undeclared identifier is reported only once
21: error: for each function it appears in.)
といった課題で、以下のプログラムを作ってみたのですが、上手くいかず躓いているのでお助けいただけるとありがたいです。
#include <stdio.h>
void A(int);
int main(void){
int m;
printf("Capital Letter: ");
scanf("%d",&m);
A(10);
return 0;
}
void A(int n){
int i;
for(i=1;i<=n;i++)printf("%d",m);
puts("");
}
以下のエラーコードが出ます。
21: error: `m' undeclared (first use in this function)
21: error: (Each undeclared identifier is reported only once
21: error: for each function it appears in.)