ugh, more problems here.
now i am trying to format the output and am having trouble getting things to look the way i would like them too.
here is my code:
my output is not being aligned like i would like it. its coming out like this: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 x, 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 */ /* Display each clients information */ printf ("\nACCOUNT LAST NAME BALANCE"); for (x = 0; x < numClient; x++) { printf ("\n%-4ld %s %12.2f", client[x].accntNum, client[x].name, client[x].balance); } /* end for */ printf ("\n"); return 0; } /* end main */
basically i need to right justify the balance number so the decimal points line up.Code:Welcome to Client Account Information Services Enter number of clients to be used: 2 Enter account number: 100 Enter last name: washington Enter balance: 100 Enter account number: 200 Enter last name: smith Enter balance: 200 ACCOUNT LAST NAME BALANCE 100 washington 100.00 <----how can i get the balance 200 smith 200.00 number to line up the decimals? Press any key to continue . . .
i have not been able to get this to work so far. i need the last names to line up by the first letter so using something like %15s is out of the question because that lines up the names by the last letter.
any help is appreciated!



LinkBack URL
About LinkBacks



