0
I’m trying to return the lowest value using the va_args
, which supports several arguments, but it always returns the same number: -13227;
#include <stdio.h>
#include <limits.h>
#include <stdarg.h>
int minimo(int args, ...)
{
int elemento, min;
va_list valist;
va_start(valist, args);
min = INT_MAX;
for(int i=0; i<args; i++)
{
elemento = va_arg(valist, int);
if(elemento < min)
min = elemento;
}
va_end(valist);
return min;
}
int main()
{
int num = minimo(8, 5, 3, 7, 12, 6);
printf("%d\n", num);
return 0;
}
And the variable changes min
of int for unsigned int, always returns 0.
https://ideone.com/9TNKLp
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero