質問編集履歴
1
エラーの例
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,95 @@
|
|
1
1
|
C言語の問題で関数の実引数でよくエラーが出てしまいます。
|
2
2
|
|
3
3
|
なにかコツや考え方などがありましたら教えてください。(答えにくかったらゴメンナサイ)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```C
|
8
|
+
|
9
|
+
#include <stdio.h>
|
10
|
+
|
11
|
+
#include <stdlib.h>
|
12
|
+
|
13
|
+
void quorem(int a, int b, int *q, int *r);
|
14
|
+
|
15
|
+
int main(int argc, char *argv[]) {
|
16
|
+
|
17
|
+
int dvnd, dvsr;
|
18
|
+
|
19
|
+
int quo, rem;
|
20
|
+
|
21
|
+
if (argc<3) {
|
22
|
+
|
23
|
+
printf("At least 2 arguments required!\n");
|
24
|
+
|
25
|
+
exit(-1);
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
dvnd = atoi(argv[1]);
|
32
|
+
|
33
|
+
dvsr = atoi(argv[2]);
|
34
|
+
|
35
|
+
quorem(dvnd, dvsr, &quo, &rem); /*ここの &quo &rem の部分や*/
|
36
|
+
|
37
|
+
printf("quotient : %d\n", quo);
|
38
|
+
|
39
|
+
printf("remainder: %d\n", rem);
|
40
|
+
|
41
|
+
return 0;
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
void quorem(int a, int b, int *q, int *r) {
|
46
|
+
|
47
|
+
*q = a / b;
|
48
|
+
|
49
|
+
*r = a % b;
|
50
|
+
|
51
|
+
return;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
```C
|
60
|
+
|
61
|
+
#include <stdio.h>
|
62
|
+
|
63
|
+
#include <stdlib.h>
|
64
|
+
|
65
|
+
void limit(int min, int max, int * pn);
|
66
|
+
|
67
|
+
int main(void) {
|
68
|
+
|
69
|
+
int num;
|
70
|
+
|
71
|
+
printf("? "); scanf("%d", &num);
|
72
|
+
|
73
|
+
limit(60, 80, &num); /*この部分を min max &pn と書いていてしまった。 */
|
74
|
+
|
75
|
+
printf("%d\n", num);
|
76
|
+
|
77
|
+
return 0;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
void limit(int min, int max, int * pn) {
|
82
|
+
|
83
|
+
if (min > *pn){
|
84
|
+
|
85
|
+
*pn = min;
|
86
|
+
|
87
|
+
} else if (*pn > max){
|
88
|
+
|
89
|
+
*pn = max;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|