| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sorting an array of random words....please help
K guys, I have a bit of a problem sorting an array of random words. The thing is like this: 2 functions create an array 'data' that contains random words. My task is to create some functions, that combined together and used in the selection sort algorithm and in the quicksort algorithm will result in the array being sorted.
So far, so good. for example, if my functions will be like: 'void selection(char *data, int size)' then everything will be perfect, but the major problem that I have is that I have to declare the function in this way: 'void selection (void *data, int size)' Well, so far, so good again...because inside the function i can declare sth like this: 'void selection (void *data, int size)' { char *s; s=(char *)data; } and now i have access to the data variable that I will be transferring from the main program.It works perfect, as long as I have only one word, not a WHOLE ARRAY. When I have an array of strings, I cannot see the array inside the function 'selection'. Aparently I can see only it's first value, but the others are gone. I have tried many things, but none of them seems to work(includeing a clever way: typedef a structure that contains an array of strings, and then using a pointer to that structure...but none of them seems to work.) Please give any advice, if any. I don't need the entire code, I know perfectly what I have to do, it's just that I'm stuck with the process of transfering an array to a function that takes as a parameter a void pointer! Thank and Best Regrds, Veilside |
|
#2
|
|||
|
|||
|
Got it, I found my silly mistake, thanks anyway!
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Sorting an array of random words....please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|