[for C]
i'm trying to write a function called:
void first_last( char *s[], int n, char **first, char **last )
given an array s of n strings, it is supposed to find the first and last string in the array according to alphabetical order and then store those values into **first and **last.
i have to use the function on an array of 8 words afterwards.
____
i am trying to figure out how to go about this but it's so difficult for me to wrap my head around pointers to pointers. i understand that char*s will point to the first string in the array of strings, and that char **s will point to the first letter in the first word in the array of strings.
but i do NOT understand how i can go about testing every first letter of every first word. i know you can increment a pointer like ++char* in order to move to the second word, but how can i go about comparing the first letter in every word for 8 words? is it possible to do something like char*[n] in order to reference the nth string in my array of n strings?
can someone please give me some guidance on how to start thinking about this?
thanks!
-mrd
This post has been edited by mrdmrd: 21 October 2010 - 01:20 PM

New Topic/Question
Reply




MultiQuote





|