| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Question with aligning
for example my output is this:
Tedd, Andrew D 50.00 F Jason, May D 54.90 C Love, Angel D 45.00 F But i want it to be all aligned up in a dtraight column starting from "D". So the columd with D would but straight aliggned. How would i do that. I tries using setw but it won't solve my problem |
|
#2
|
|||
|
|||
|
Use setw() function.
|
|
#3
|
|||
|
|||
|
Oops,sorry I did not read that you mentioned about setw().
in that case, there is a function that lets you write text from specific point. I can't remember that function name. Try, gotoxy() |
|
#4
|
|||
|
|||
|
Depending on how you're storing your data you could just use the printf flags
Code:
struct Whatever
{
char name[20];
double num;
}myStruct;
int main(int argc, char* argv[])
{
strcpy(myStruct.name, "John, Doe");
myStruct.num = 12.34;
printf("\n%15s%10.2f", myStruct.name, myStruct.num);
getchar();
return 0;
}
|
|
#5
|
||||
|
||||
|
you could also use the tab character to align everything by tabs: printf("X \t Y")
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Question with aligning |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|