Aligned plain-text CLI table renderer in ANSI C

C
#include <stdio.h>
#include <string.h>
void print_table(const char *head[], const char *cell[], int cols, int rows) {
    if (cols < 1 || cols > 8) return;
    size_t w[8] = {0};
    for (int c = 0; c < cols; c++) w[c] = strlen(head[c]);
    for (int r = 0; r < rows; r++)
        for (int c = 0; c < cols; c++) {
            size_t n = strlen(cell[r * cols + c]);
            if (n > w[c]) w[c] = n;
        }
    for (int c = 0; c < cols; c++) printf("%-*s%s", (int)w[c], head[c], c == cols - 1 ? "\n" : " | ");
    for (int c = 0; c < cols; c++) printf("%-*.*s%s", (int)w[c], (int)w[c], "----------------------------------------", c == cols - 1 ? "\n" : "-+-");
    for (int r = 0; r < rows; r++)
        for (int c = 0; c < cols; c++) printf("%-*s%s", (int)w[c], cell[r * cols + c], c == cols - 1 ? "\n" : " | ");
}