Created
November 22, 2021 21:31
-
-
Save lostsh/feee5576d5cbb83ab3888d78d6e861e1 to your computer and use it in GitHub Desktop.
parrotsay
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
#include <stdio.h> | |
void showMessage(int, char**); | |
void showParrot(int); | |
size_t strlen(char*); | |
int main(int argc, char **argv){ | |
if(argc <= 1){ | |
printf("Usage: %s [message]\n", argv[0]); | |
return -1; | |
} | |
showMessage(argc, argv); | |
showParrot(7); | |
return 0; | |
} | |
void showParrot(int shiftSize){ | |
char shift[shiftSize]; | |
for(int i=0;i<shiftSize;i++)shift[i] = ' '; | |
shift[shiftSize] = '\0'; | |
printf("%s\\ _________ \n%s \\ //// \\\\\\\\ \n%s \\ // \\\\ \n%s \\ //,-, ,-,\\\\ \n%s ||( @ ) ( @ )|| \n%s \\\\ '-` .___. `-' // \n%s || |^ ^| || \n%s \\\\ \\ / // \n%s \\\\\\ \\v/ /// \n%s \\\\ // \n%s // \\\\ \n%s /||\\ /||\\ \n%s // || || \\\\ \n%s // || || \\\\ \n%s |/ /| |\\ \\| \n%s | // \\\\ | \n%s | // ,___, \\\\ | \n%s |_/ | | | | \\_| \n%s \\____/ \\____/ \n%s \\__/ \\__/ \n%s || || \n%s || || \n%s || || \n%s '--' '--' \n", shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift, shift); | |
} | |
void showMessage(int argc, char **argv){ | |
int len = argc-2; // Ignore first arg and first space | |
for(int i=1;i<argc;i++) len+=strlen(argv[i]); | |
printf(" "); | |
for(int i=0;i<len+2;i++) printf("_"); | |
printf("\n<"); | |
for(int i=1;i<argc;i++) printf(" %s", argv[i]); | |
printf(" >\n "); | |
for(int i=0;i<len+2;i++) printf("-"); | |
printf("\n"); | |
} | |
size_t strlen(char *str){ | |
unsigned short int i = 0; | |
while (str[i] != '\0') i++; | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile
Execute
./parrotsay Typical parrotsay output \!