the program is printing memory junk, where would be the error?

Asked

Viewed 94 times

1

/* Make a program that receives two integer values, one of lower limit and the other of upper limit. Its function must print all values in the closed range defined. */

int main()
{
int max, min, n;
scanf("%i %i", &max, &min);
 n = max - min;
int vet[1000];

printf("valor max %i, e o valor min %i\n\n", max, min);
printf("os numeros entre o max e min sao:\n");
vet[1000] = funcao(max, min);

for(int i=0; i<n; i++){
 printf("%i   ", vet[i]);
}
 return 0;
}

int funcao(max,min){
int vet[1000];

for (int i=0; max >= min; max--){
 vet [i] = max;
 i++;
if (max == min){
return vet;
}}}
  • You return vet but assign to an element of an array (an integer).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.