Skip to content

Instantly share code, notes, and snippets.

@ryuichiueda
Created March 30, 2014 07:07
Show Gist options
  • Save ryuichiueda/9868853 to your computer and use it in GitHub Desktop.
Save ryuichiueda/9868853 to your computer and use it in GitHub Desktop.
/* fold.c nバイトずつ折り返す */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const* argv[])
{
if(argc != 2)
exit(1);
int i = 0;
long n = strtol(argv[1],NULL,10);
if(n <= 0 || n > 1024)
exit(1);
while(1){
for(i=0;i<n;i++){
int a = getchar();
if(a == EOF)
exit(0);
putchar(a);
}
putchar('\n');
}
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment