**
C言語で引数として3つの整数値 min, max, *pをとり *p の値が min と max の範囲にあればなにもせず,
minより小さければ *p の値をminに, maxより大きければ maxにする関数を作成したいのですがエラーがでます。
**
C言語
1 2#include <stdio.h> 3#include <stdlib.h> 4void limit(int min, int max, int * p); 5int main(void) { 6 int num; 7 printf("? "); scanf("%d", &num); 8 num = limit(min, max, &p); 9 printf("%d\n", num); 10 return 0; 11} 12void limit(int min, int max, int * p) { 13 if (min > *p){ 14 min = *p; 15 } else if (*p > max){ 16 max = *p; 17 } 18} 19 20** 21以下がエラーメッセージです。 22** 23 24teratail.c: In function 'main': 25teratail.c:10:14: error: 'min' undeclared (first use in this function) 26 num = limit(min, max, &p); 27 ^ 28teratail.c:10:14: note: each undeclared identifier is reported only once for each function it appears in 29teratail.c:10:19: error: 'max' undeclared (first use in this function) 30 num = limit(min, max, &p); 31 ^ 32teratail.c:10:25: error: 'p' undeclared (first use in this function) 33 num = limit(min, max, &p);
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。