I wanted to create a vector (dynamically allocated) where every element of the vector is taken from the command line starting from the 3rd parameter.
I wrote this:
#include <stdio.h>
#include <stdlib.h>
int main(int argn, char* argc[]) {
    if (argn < 4) {
        printf("Error: invalid parameter number. \n");
        return 0;
    } 
    float min = atof(argc[1]), max = atof(argc[2]), *v, *k;
    int dim = argn-3;
    char **p;
    v = malloc(dim*sizeof(float));
    k = v;
    for (p = argc+3; p < argc+dim; p++) {
        *k = atof(*p);
        k++;
    }
    for (k = v; k < v+dim; k++) {
        printf("%3.f ",*k);
    }
    return 0;
}
The problem is that only the first parameter seems to be taken from the command line, while others not.
Example: I launch [ProgramName] 25 30 27 28 29 32
It returns me 27.0 0.0 0.0 0.0, but it should return me 27.0 28.0 .29.0 32.0
Why isn't my code working?
Sorry for eventual grammar mistakes, I'm not english.
 
    