***THE TITLE SHOULD SAY SORTING A STRUCTURE NOT AN ARRAY!!!***
ok this is the last part i need finished for this program and its causing quite a headache.
basically im storing data in a structure and it needs to be sorted. i have figured out the general outline from information ive found on here and what ive been able to work on.
when i compile the code i am getting these errors:
and of course here is the code for the program:Code:64: parse error before `temp' 66: incompatible types in assignment
basically just need to figure out what is not correct when i am calling the 'info temp = client[x]; line or just before it.Code:#include <stdio.h> /* Define structure */ struct info { long int accntNum; char name[25]; float balance; }; /* Begin main */ main() { /* Declare variables */ struct info client[25]; int temp = 0; int x, y, numClient; /* Display opening message */ printf ("Welcome to Client Account Information Services\n\n"); /* Prompt for how many clients will have info entered */ printf ("Enter number of clients to be used: "); scanf ("%i", &numClient); /* Prompt for user to enter each clients info */ for (x = 0; x < numClient; x++) { printf ("\nEnter account number: ", x + 1); scanf ("%ld", &client[x].accntNum); fflush(stdin); /* Remove extraneous characters */ printf ("Enter last name: ", x + 1); gets (client[x].name); fflush(stdin); /* Remove extraneous characters */ printf ("Enter balance: ", x + 1); scanf ("%f", &client[x].balance); } /* end for */ /* Sort array in ascending order by account number */ for (y = 1; y < x - 1; y++) { for (x = 1; x < numClient; x++) { if (client[x].accntNum > client[x + 1].accntNum) { info temp = client[x]; client[x] = client[x + 1]; client[x + 1] = temp; } /* end if */ } /* end for */ } /* end for */ /* Display each clients information */ printf ("\nACCOUNT LAST NAME BALANCE"); for (x = 0; x < numClient; x++) { printf ("\n%7d %17s %15.2f", client[x].accntNum, client[x].name, client[x].balance); } /* end for */ printf ("\n"); return 0; } /* end main */
all help is appreciated!
(i also realize this similar question has been asked recently. i have viewed those posts but it has only got me stuck at this point. i have a feeling its something simple i am not noticing, but sometimes we all need a fresh set of eyes to look at things)


