Is it possible to have a variable alignment instead of a constant (10 in this example)?Code:void PrintMatrix(int **matrix, int rij, int kolom) { int i, j; printf("Resultaat: \n"); for (i = 0; i < rij; i++) { printf("["); for (j = 0; j < kolom - 1; j++) printf("%-10i", *(*(matrix + i)+j)); printf("%-10i", *(*(matrix + i)+j)); <------- printf("]\n"); } printf("\n"); }
so something like this:
printf("%-(%i)i", numbers(*(*(matrix + i)+j)), *(*(matrix + i)+j)); <-------
[ where numbers is a function that calculates the #amount of digits an integer has.
numbers(321) = 3. ]



LinkBack URL
About LinkBacks




