From 9fae5d516012e2c0802105e67c79e2587a22b9dc Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 1 Jan 2020 22:37:37 -0500 Subject: Inital commit --- hw2/main.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 hw2/main.c (limited to 'hw2/main.c') diff --git a/hw2/main.c b/hw2/main.c new file mode 100644 index 0000000..d6312ea --- /dev/null +++ b/hw2/main.c @@ -0,0 +1,107 @@ +#include +#include + +/* + ///// ______________ + d|o-o|b | | + \O/ .:______________| + ` +*/ +#define MAN_LINE_1 "\ + //// _______________________________________________________________" + +#define MAN_LINE_2_START "\ + d|o-o|b |" + +#define MAN_LINE_3_START "\ + \\O/ .:" + +#define MAN_LINE_4_START "\ + ` |" + +#define MAN_LINE_BLANK "\ + |" + +int main(int argc, char **argv){ + char c = '\0'; + int column = 0; + int line = 0; + int i; + //Grab until the new line character + while(c != '\n'){ + //Only upercase if it's the first character + if(c == '\0'){ + c = getchar(); + //and it's between a and z + if(c >= 'a' && c <= 'z'){ + //223 = b 1101 1111 + c = c & 223;//Set the 32 bit to 0 + } + }else{ + c = getchar(); + } + if(c == '\n') break; + if(line == 0){ + printf("%s\n",MAN_LINE_1); + line++; + column = 0; + } + if(line == 1 && column == 0){ + printf("%s",MAN_LINE_2_START); + column = strlen(MAN_LINE_2_START); + } + putchar(c); + column++; + if(line == 1 && column == 78){ + printf("|\n"); + printf("%s",MAN_LINE_3_START); + line++; + column = strlen(MAN_LINE_3_START); + } + if(line == 2 && column == 78){ + printf("|\n"); + printf("%s",MAN_LINE_4_START); + line++; + column = strlen(MAN_LINE_4_START); + } + if(line >= 3 && column == 78){ + printf("|\n"); + printf("%s",MAN_LINE_BLANK); + line++; + column = strlen(MAN_LINE_BLANK); + } + } + //Don't break, fall through to finish whatever lines we havn't done yet + switch(line){ + case 1: + i = 78 - column; + while(i-- > 0) + printf(" "); + printf("|\n"); + printf("%s",MAN_LINE_3_START); + column = strlen(MAN_LINE_3_START); + case 2: + i = 78 - column; + while(i-- > 0) + printf(" "); + printf("|\n"); + printf("%s",MAN_LINE_4_START); + column = strlen(MAN_LINE_4_START); + default: + //Finish off the line + i = 78 - column; + while(i-- > 0) + printf(" "); + printf("|\n"); + //Then print our bottom border + printf("%s",MAN_LINE_BLANK); + column = strlen(MAN_LINE_BLANK); + i = 78 - column; + while(i-- > 0) + printf("_"); + printf("|\n"); + break; + } + + return 0; +} -- cgit v1.2.3-70-g09d2