Results 1 to 9 of 9
Hey guys, I want to print out something similar to the following in evenly spaced columns. But I don't know to how to. I've tried to do it, but its ...
- 11-06-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
Printing out data in evenly spaced columns
Hey guys, I want to print out something similar to the following in evenly spaced columns. But I don't know to how to. I've tried to do it, but its not how I want it to be printed out. This info is read from a data file.
Square Root sqrt 10
Exponential Function exp 10
Natural Logarithm log 10
Logarithm log10 10
Absolute Value fabs 10
and so on... The second row is suppose to be straight, I know its a little slightly not straight.
But I do not know how to print out so that the second is all evenly matched and spaced out.
This is what I have so far..
for (i = 0; i < num; i ++)
{
printf("%s %5s %10d", name, function, number);
}
I thought that it would be something similiar to this, but it doesn't work. Does anyone have any other way to doing this in Linux. Thanks.
- 11-06-2007 #2
When does your professor or instructor say this assignment is due?
- 11-06-2007 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
Square Root sqrt 10
Exponential Function exp 10
Natural Logarithm log 10
Logarithm log10 10
Absolute Value fabs 10
It is suppose to look like that, I didn't realize it printed out wrong.
- 11-06-2007 #4Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
It still won't print out the way I want it to .. But the starting from sqrt 10 and exp , log, fabs 10, it suppose to be in a separate column spaced out from the Square Root section.
- 11-06-2007 #5Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
Exponent__________Exp
Logarithm__________Log
Natural Log_________Log
Absolute Value______Abs
Kind of like this.. But without the lines
- 11-07-2007 #6
- 11-07-2007 #7Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
I would but the thing is the data is read from a data file and the words in the first column are all different lengths and then some of the words in the second column are also all different lengths.
- 11-08-2007 #8
Well.. if you put for an example 3 or 4 tabs between columns, fields length shouldn't be a problem. Except of course you don't have a whole sentence as a filed value. How long may the longest value be?
- 11-08-2007 #9Just Joined!
- Join Date
- Sep 2007
- Posts
- 13
Well some of the lines are a lot longer than the others, such as one may be as long as
if you put for an example 3 or 4 tabs between__________COLUMN
if you put for an___________________________________COLUMN
if you put for an example 3 or 4______________________COLUMN
if you put for_____________________________________COLUMN
and I want print them using one print statement in a loop.


Reply With Quote
