>> line 20: fflush(stdin);
fflush() is only guaranteed to work with output streams, not input streams.
>> line 21: gets(p[i])
Two problems:
- never ever use gets() because it may write beyone the bounds of the array, causing your program to crash. Use fgets() instead.
- Variable p is an array of 40 pointers. You have to allocate memory for those pointers before they can be used. Suggest you code it something like this:
char p[40][80]; , which is an array of 40 character arrays, and each array can hold up to 80 characters.
>>line 38: if( strcmp((p+i),(p+j)) > 0 )
Delete that and uncomment the algorithm on line 44.
Last edited by Ancient Dragon; Nov 6th, 2009 at 10:28 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Offline 21,963 posts
since Aug 2005