storing dynamically allocated pointers
hi still struggling with pointers here,i want to put in names and then dynamically allocate memory to store the names. But how do i store he pointer given by malloc into the array of pointers.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void input (char *array[]){
char name[21]; //first storing name into name[], 20 char max
for(i=0; i<10; i++){
fgets(name,20,stdin);
... = (...) malloc (sizeof (char) * strlen(name));
}
return
}
int main (void){
char *names[10]; //room for 10 pointers
int count;
return 0;
}