I don't know what is the correct way to allocate memory dynamically:
I have a .csv file which has like 50 lines and I need to allocate enough space in memory to save each line of the file in one space of the struct vector.
Also, I know that the return of malloc is the first position of the allocated memory space.
Example:
typedef struct{
int a;
float b;
char name[10]; //This will be set dynamically too, later...
}my_struct;
int main(){
int *p_array;
size_t vector_size = 2; //Same as doing: my_struct struc[2] ?
p_array = (int *) malloc(vector_size * (int));
my_struct struc[p_array];
return 0;
}
Is it right? If not which is the right way of doing it. I got no errors, but I don't know why it doesn't seems right.