I have been stuck on this all day. I want to be able to create a string array in C, and pass that array to the PrintStuff function. I don't want to change my parameters to PrintStuff, but still make it work. Any help please?
void PrintStuff(const char **arr) {
for (int i = 0; i < 5; ++i) {
printf ("%s\n", arr[i]);
}
}
int main ()
{
//This works
//char * array[5] = { "this", "is", "a", "test", "megan"};
//This doesn't work
char * array[5];
for (int i=0;i<5;i++)
{
//scanf("%9s", array[i]);
fgets(array[i], 10, stdin);
}
Sort(array, 0, 5 - 1);
}
It doesn't do anything and I get this warning that says
passing 'char *[5]' to parameter of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
I've got no ideas what that means or how to fix it, HELP ME PLEASE!!!!!!!
mallocbut make sure you check the return value for errors. You should do that forfgetstoo.