Home>
This site http://9cguide.appspot.com/15-q.htmlThe 15-p exercises in c language that I remember hardly seem to have different answers. I tried to fix the source myself, but it still gives an error.
I don't think anything is wrong in the sense of sending the array address to another function as an argument. What is wrong?
A description error was found in "15th line".
warning
Array initialization is incorrect.
A description error was found in "15th line".
A description error was found in "Line 23".
"Maxmin" has been redefined. Make sure that i am not using the same name as before and that the function description is correct.
warning
Array initialization is incorrect.
Applicable source code
## include<stdio.h>
void maxmin (int array [], int max, int min);
int main (void)
{
int i = 0, array [10], max, min;
do {
printf ("% d th number:", i + 1);
scanf ("% d",&array [i]);
i ++;
} while (array [i-1]! = -1);
maxmin (array,&max,&min);
printf ("Maximum value% d: Minimum value% d \ n", max, min);
return 0;
}
void maxmin (int * array, int * max, int * min)
{
int i = 0;
* max = 0;
* min = 100;
while (array [i]! = -1) {
if (array [i]>max) max = array [i];
if (array [i]<min) min = array [i];
i ++;
}
}
I thought that the value of the argument was wrong, so I changed it, but I got an error.
Supplemental information (FW/tool version etc.)EasyIDEC
-
Answer # 1
-
Answer # 2
Fixed. The correction part has a comment of "// correction".
First line is
"## include"
I think it was a copy mistake (two #), so I modified it, but I didn't add any comments.# include
void maxmin (int array [], int * max, int * min);// correct int main (void) { int i = 0, array [10], max, min; do { printf ("% d th number:", i + 1); scanf ("% d",&array [i]); i ++; } while (array [i-1]! = -1); maxmin (array,&max,&min); printf ("Maximum value% d: Minimum value% d \ n", max, min); return 0; } void maxmin (int * array, int * max, int * min) { int i = 0; * max = 0; * min = 100; while (array [i]! = -1) { if (array [i]>* max) * max = array [i];// fix if (array [i]<* min) * min = array [i];// fix i ++; } }
Related articles
- [c language, arrays and pointers] i don't know why this is the behavior! please tell me
- sorting arrays with functions that do not use c language pointers
- c language: handling of command line arguments and strtol
- c language: the total number of arrays is not calculated well
- c language coredump solution
- about conditional statements in c language
- question in c language standard (jis x3010:2003)
- c language character string display
- i want to compile a c language program successfully
- read image file in c language and apply sobel filter
- about c language variables
- c language queue dequeue
- warning that the c language type is different
- divide hexadecimal 1abf2454f185 in c language and convert to integer
- c language programming about power calculation
- c language program to display average weight
- implementation of c language queue
- pointer reference in c language structure
- how to reverse lookup with c language enum
- i do not understand the problem of the c language while statement
Trends
In function definition
In this way, it is assumed that "integer array", "integer" and "integer" will come.
But what you are actually passing
"Integer type array" "integer address" "integer address" is passed.
I think it would be ideal to set the
max
andmin
values on the function side, soTry to match the definition or call.
Even if you remove it, you can just try the opposite, so try it for now.
[Revised question text]
In C language, there is a declaration part (prototype declaration) and an implementation part of a self-made function.
In both cases, "return value type", "function name", and "argument" must be written, and they must be written in the same way.
Rewrite the prototype declaration as well as the implementation part.