TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

returning a value from an array



ok now i need this function to return a value that is in the array
char *array[30] = {0};
char *server_c;
char item_chossen[5];
int temp;

/* my fgets that reads from a file and puts the strings into the array goes
here */
printf("which on do you want\n");
1 string1
2 string2
.....
scanf("%s", &item_chossen);
temp = atoi(item_chossen);
/* i want to return the value in arry[temp - 1] to the calling function */
server_c = &array[(temp - 1)];
return server_c;
this does not work; i get warning: assignment from incompatible pointer w/o
a cast
warning: return makes integer from pointer w/o a cast
the function is set
char funtion();
so i hope this is enough to show you where i am missing the boat.....

i have just never thought to return a value in an array before.
TIA