I'm having a problem with a function meant to insert random C-strings into an array. I've read a few other questions about this on stackexchange, but none seem to work for me.
void rand(const char *tab[], int n){
int i, j;
char c[10];
for(i=0; i<n; i++){
for(j=0; j<10; j++){
c[j]= rand()%26 + 97;
}
tab[i]=c;
}
}
When trying to print it out, I get a blank screen, as if the array is empty. I declared the array as const char *tab[]
and use the function rand(tab, 5)
. What could be wrong?