Skip to content

Instantly share code, notes, and snippets.

@Aaron1011
Created November 25, 2012 01:30
Show Gist options
  • Save Aaron1011/4142032 to your computer and use it in GitHub Desktop.
Save Aaron1011/4142032 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define LINECOL 20 /* "fold" after this column */
int main()
{
int c, i, j, lastchar;
int str[LINECOL];
for (i = 0; i <= LINECOL; i++)
str[i] = 0;
i = 0;
lastchar = 19;
while ((c = getchar()) != EOF)
{
if (i >= LINECOL)
{
str[i] = c;
for (j = 0; j <= lastchar; j++)
printf("%c", str[j]);
printf("\n");
i = -1;
}
else
{
str[i] = c;
if (c != ' ' && c != '\t')
lastchar = i;
}
++i;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment