Created
March 30, 2014 07:07
-
-
Save ryuichiueda/9868853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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