![]() |
| ||
| Qsort Pointer To Arrays Of Structs I have read in a file, and i can print it out successfully, but i must sort the pointer to the array of structures. below is my code. I must sort the phone book in ascending order by zip code. If anyone could please help that would be great. 1 #include <stdio.h> |
| ||
| Re: Qsort Pointer To Arrays Of Structs Try this int compare(const void *p1, const void *p2) |
| ||
| Re: Qsort Pointer To Arrays Of Structs Thank you, i found that i had to change a few things, notably i had to change my typedef struct to this: typedef [COLOR="Red"]struct pb_s[/COLOR]{making that pb_s at the top of the struct definition is what made it possible to work. |
| ||
| Re: Qsort Pointer To Arrays Of Structs Good I'm glad you got the problem...sorted, har har. Not sure if your compiler supports it but another thing you can do is struct ADDRESS { char name[50]; char street[50]; char city_state[50]; int zip; } ; if you are going to use it locally If you want to share it between modules you can put it in a header file as volatile struct ADDRESS { } address ; so on & so forth |
| All times are GMT -4. The time now is 3:06 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC