Add printf formatter
This commit is contained in:
parent
cc8beab255
commit
e2042e677f
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
|||
|
||||
project(programmingquest LANGUAGES C)
|
||||
|
||||
SET(CHALLANGE namegen)
|
||||
SET(CHALLANGE format)
|
||||
|
||||
add_executable(binary
|
||||
src/${CHALLANGE}.c
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define COLIM 16
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char c;
|
||||
int count=0;
|
||||
if (argc<1) {
|
||||
fprintf(stderr, "No format provided!\n");
|
||||
return 1;
|
||||
}
|
||||
while ((c=getchar())!=EOF) {
|
||||
printf(argv[1], c);
|
||||
if (count++==COLIM) {
|
||||
printf("\n");
|
||||
count=0;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue