I want to make a table like this:

Seq. Name Class Seat VIP? Mileage(km)
==== =============== ===== ==== ====== ==========
1. Peter B 5A VIP 1046km
2. David F 1A VIP 2150km
......

Do I need to use for loop, strncpy to do so?
Or do I need to use some other methods?
I am learning objected oriented programming and I just know it up to strings, pointer, array.
Thank you very much!

You can use printf() or cout with formatting to print a format like that.
As a matter of fact, you can do it a multitude of ways, but I'd stick with printf or cout.

You can choose use spaces or tabs for your layout depending on how much of the console you need to use.

The function you use will depend on how you get the data.
If you are just typing it in, you can force the layout in a string.
If you are reading it from another source and it is already formatted, just store it in a string and do the output.
If it is coming from a parsed source (like a database), you will need to read the fields and create the formatted string.

Other considerations are:
1) Will this table be stored in a file for loading into Excel (or other)?
2) Will this table be used for printing?
2a) If so: will the font used for printing affect the layout?

Did I go too far?

I want to make a table like this:

Seq. Name Class Seat VIP? Mileage(km)
==== =============== ===== ==== ====== ==========
1. Peter B 5A VIP 1046km
2. David F 1A VIP 2150km
......

Do I need to use for loop, strncpy to do so?
Or do I need to use some other methods?
I am learning objected oriented programming and I just know it up to strings, pointer, array.
Thank you very much!

Your best bet is to figure out how to do this on paper then figure out what code is needed to accomplish it.

Write down where you start from -- in detail (do you have data somewhere already? Where?)
Write down what you need to accomplish (from the starting point to the finish)
Write down what you want to have at the end -- in detail.

Now take that center statement and start breaking it down into tasks.
-- given the starting point, what tasks needs to happen to get to the finish?
Break those tasks into smaller and smaller steps.
When it's as small as you can get, look for clues to the functions you need.
Now, you can start coding.

This article has been dead for over six months. Start a new discussion instead.