I need to relocate my vector to every new entry, any ideas?

Asked

Viewed 36 times

1

Implement a program that requests a sequence of values to be stored in a dynamically allocated vector and reallocated to each new entry.

#include <stdio.h>
#include <stdlib.h>

int main () {

    float *v;
    int N,i;
    v = (float *)malloc(N * sizeof(float));

    printf("Qual o tamanho do vetor: \n");
    scanf("%d", &N);

    for (i = 0; i < N; i++) {

    printf("\nDigite valores entre zero e dez para a posicao %d do vetor: ", i);
    scanf("%f",&v[i]);
  }
  for (i = 0;i < N; i++)
  {
    printf("\n%.2f\n",v[i]);
  }

    free(v);
return 0;
}
No answers

Browser other questions tagged

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