Align columns/C: Difference between revisions

m
no edit summary
(replaced with clean method)
mNo edit summary
Line 3:
<lang c>#include <stdio.h>
 
const char *str =
"Given$a$text$file$of$many$lines,$where$fields$within$a$line$\n"
"are$delineated$by$a$single$'dollar'$character,$write$a$program\n"
Line 11:
"justified,$right$justified,$or$center$justified$within$its$column.";
 
void align(const char *in, char alignment)
{
int col, i, l, r;
int w[1024] = {0};
const char *s = in;
 
for (s = in, i = col = 0; s[i]; s += i + 1) {
Line 22:
if (i > w[col]) w[col] = i;
 
if (col++ >= 1024) abort(); /* artificalartificial limit */
 
if (s[i] == '\n') col = 0;
Anonymous user