Skip this error:
warning: format '%p' expects argument of type 'void //**', but argument 2 has type 'int' [-Wformat=] scanf("%p", vector[i] );
This is my code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int *vector;
int tam=0;
int minimo=10000;
printf("Introduce una longitud del array:\n" );
scanf("%i", &tam);
vector=(int*)malloc(sizeof(int)*tam);
for (int i = 0; i <=tam; i++) {
printf("Introduce un valor para posicion %i\n",i );
scanf("%p", vector[i] );
}
//hayamos minimo
for (int j = 0; j <= tam; j++) {
if (vector[j]<minimo) {
minimo=vector[j];
}
}
printf("%i", minimo );
free(vector);
return 0;
}
Check this thread. Source: print the memory location of a variable (or pointer)
What you need is to ask for an integer; the expression
vector[i]
is equivalent to*( vector + i )
, hence the compiler warning; instead of a pointer, you're passing an integer.Change your code to