PDA

Click to See Complete Forum and Search --> : qsort and stuff


richy
May 11th, 2001, 09:33 AM
Few, hopefully quick questions:

1. I've created a 2D array in C and now want to sort it by the third column. Is there an easy way or do I have to program the sort by hand. Someone mentioned qsort or something, but I'm not sure whether thats usable or not.

2. Like in VB, are there any functions where certain parts of a string can be picked e.g. Left, Mid, or Right functions in VB.

3. I've read in a few bits of data from a text file and put them into an array using the following line:

Where studnum and part are checked accordingly

strcpy(students[studnum][part],emptylet);
sprintf(students[studnum][part],"%s",reading);
printf("%i %i %s\n",studnum, part, students[studnum][part]);

On the above printf my values are appearing correctly, and yet on the following line I have to test it:

printf("%i %s is the first bit of data\n",strlen(students[2][1]),students[2][1]);

The data printed out is two sections together. Can anybody tell me why.

I've made the program available for people to check out. I apologise for the probably long winded programming, but I haven't done C for 6 years!