i am currently confused as to how i can pass an array of strings to a function. I have created a one-dimensional array. The method that i have done works but it seems redundant and i think there is a better way of doing this yet i am unsure how. I am trying to find a way where i can pass all 4 elements to the function at one time.
Here is the sample of my code.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void sort(char *,char *,char *, char *);//Function prototype
int main()
{
char *string_database[4]={'\0'};
string_database[0]="Florida";
string_database[1]="Oregon";
string_database[2]="California";
string_database[3]="Georgia";
sort(string_database[0],string_database[1],string_database[2],string_database[3]);
return 0;
}
void sort(char *string1, char *string2, char *string3, char *string4)
{
printf("The string is= %s\n",string1);
printf("The string is= %s\n",string2);
printf("The string is= %s\n",string3);
printf("The string is= %s\n\n\n",string4);
}
Thank you in advance, i appreciate any replies to my problem.