# How to make all table cells center aligned?

I have this code which works fine

\begin{table}[ht]
\caption{Table Data }
\centering
\begin{tabular}{c c c c}    % centered columns (4 columns)


Now i have the dynamic headers so i have to hard code this line every time accoring to headers

begin{tabular}{c c c c}


is there any way to apply that to all coumns instead of all like this

begin{tabular}{c} for all

-
You can use, for example, \begin{tabular}{*{5}{c}} to indicate five columns of c type. – Gonzalo Medina May 1 '13 at 1:09
so it means i need to know before hand how many columns should be there – user17 May 1 '13 at 1:24

You can specify a number of columns which is more that you need -- there is no problem with extra column specification, AFAIK. Also, as per Gonzalo Medina's comment you can use the {*{15}{c}} notation to specify a maximum of 15 columns.

## Code:

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{c c c c c c c c c c c c c c c} \toprule
One & Two \\ \cmidrule{1-2}
1  & 2   \\ \bottomrule
\end{tabular}
\begin{tabular}{*{15}{c}} \toprule
One & Two & Three \\ \cmidrule{1-3}
1  & 2   & 3 \\ \bottomrule
\end{tabular}
\end{document}

-