Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * For: https://youtu.be/1zxFuMawrDc
- *
- * To use this, you'll need three files in the same directory as the
- * executable: cake.txt, pirate.txt and one.txt
- *
- * The files should be filled with the lyrics to Crazy Cake,
- * You Are a Pirate, and We Are Number One, respectively.
- *
- * Some lyrics are provided at the end of this file
- */
- #include <stdio.h>
- #include <string.h>
- FILE *fs[3];
- size_t ftracker = 0;
- int
- chcmpi(char ch1, char ch2)
- {
- if(ch1 >= 'A' && ch1 <= 'Z')
- ch1 += 32;
- if(ch2 >= 'A' && ch2 <= 'Z')
- ch2 += 32;
- return ch1 == ch2;
- }
- // case-insensitive implementation of strchr
- int
- strchri(char *str, char chr)
- {
- while(*str)
- if(chcmpi(*(str++), chr))
- return 1;
- return 0;
- }
- // case-insensitive implementation of strncmp but it returns a boolean instead of an error code
- int
- strncmpi(const char *str1, const char *str2, size_t len)
- {
- for(size_t i = 0; i < len; i++)
- if(!chcmpi(str1[i], str2[i]))
- return 0;
- return 1;
- }
- void
- ban(size_t selfilen)
- {
- if(fs[selfilen]){
- fclose(fs[selfilen]);
- fs[selfilen] = NULL;
- }
- }
- int
- getwd(char *wbuf, FILE *f)
- {
- int c;
- if(f == NULL){
- ftracker++;
- return 0;
- }
- while((c = fgetc(f)) != EOF && !strchr(" \n\t\r", c))
- *(wbuf++) = c;
- if(c == EOF)
- ban(ftracker % 3);
- return 1;
- }
- int
- checkwd(char *wbuf)
- {
- char *words[] = {"cake", "pirate", "one"};
- char *selword = words[ftracker % 3];
- return strncmpi(selword, wbuf, strlen(selword));
- }
- int
- all_banned(void)
- {
- return fs[0] == NULL && fs[1] == NULL && fs[2] == NULL;
- }
- int
- main()
- {
- char wbuf[200];
- fs[0] = fopen("cake.txt", "r");
- fs[1] = fopen("pirate.txt", "r");
- fs[2] = fopen("one.txt", "r");
- while(!all_banned()){
- memset(wbuf, 0, 200);
- if(!getwd(wbuf, fs[ftracker % 3]))
- continue;
- if(checkwd(wbuf))
- ftracker++;
- else
- printf("%s ", wbuf);
- }
- return 0;
- }
- /*
- Lyrics:
- =============================
- === Crazy Cake (cake.txt) ===
- =============================
- I'll pile on the candy, it's such a pretty sight.
- It makes the food taste a dandy, but my tummy hurts all night.
- I'll put in some ingredients, but keep the rest for me.
- I'm not just disobedient, I'm careful cant you see?
- It's a piece of cake to bake a pretty cake. If the way is hazy,
- You gotta do the cooking by the book. You know you cant be lazy.
- Never use a messy recipe, the cake will end up crazy.
- If you do the cooking by the book...
- Then you'll have a cake.
- We gotta have it made.
- You know that i love cake.
- Finally, it's time to make a cake.
- Making food is just like science, (make a make)
- With tools that blend and baste. (make a make)
- And every fun appliance,
- Gives the food a different taste. (HEY!)
- It's a piece of cake to bake a pretty cake. If the way is hazy,
- You gotta do the cooking by the book. You know you cant be lazy.
- Never use a messy recipe, the cake will end up crazy.
- If you do the cooking by the book...
- Then you'll have a cake.
- We gotta have it made.
- You know that i love cake.
- Finally, it's time to make a cake.
- We gotta have it made.
- You know that i love cake.
- Finally, it's time to make a...you gotta do the cooking by the book. Cake!
- =====================================
- === You Are a Pirate (pirate.txt) ===
- =====================================
- Do what you want, 'cause a pirate be free,
- YOU ARE A PIRATE!
- Yar har, fiddle di dee,
- Being a pirate is alright to be,
- Do what you want 'cause a pirate be free,
- You are a pirate!
- (spoken)You are a pirate!
- (crowd)Yay!
- We've got us a map, (a map!)
- To lead us to a hidden box,
- That's all locked up with locks! (with locks!)
- And buried deep away!
- We'll dig up the box, (the box!)
- We know it's full of precious booty!
- Burst open the locks!
- And then we'll say HOORAY!
- (girl's voice)Yar, har, fiddle di dee.
- If you love to sail the sea,
- You are a pirate!
- (spoken)Weigh anchooor!
- Yar har, fiddle di dee,
- Being a pirate is alright with me!
- Do what you want 'cause a pirate is free,
- You are a pirate!
- Arr yarr, ahoy and avast,
- dinky-dink-dink-a-dinkadefast!
- Hang the black flag
- At the end of the mast!
- You are a pirate!
- Hahahahaha! (Yay!)
- We're sailing away (set sail!),
- Adventure awaits on every shore!
- We set sail and explore (ya-har!)
- And run and jump all day (Yay!)
- We float on our boat (the boat!)
- Until its time to drop the anchor,
- Then hang up our coats (aye-aye!)
- Until we sail again!
- (girl's voice)Yar, har, fiddle di dee.
- If you love to sail the sea,
- You are a pirate!
- Laaaand ho!
- Yar har, fiddle di dee,
- Being a pirate is alright with me!
- Do what you want 'cause a pirate is free,
- You are a pirate!
- (spoken)Yar har, wind at your back, lads,
- Wherever you go!
- (singing)Blue sky above and blue ocean below,
- You are a pirate!
- Hahahahahaha!
- (spoken)You are a pirate!
- Heh-heh-heh-heh-heh-heh-heh.
- ===================================
- === We Are Number One (one.txt) ===
- ===================================
- Hey! We're Number One Hey! We're Number One
- Now listen closely Here's a little lesson in trickery This is going down in history If you wanna be a Villain Number One You have to chase a superhero on the run
- Just follow my moves, and sneak around Be careful not to make a sound Shh No, don't touch that!
- We're Number One Hey! We're Number One
- Ha ha ha Now look at this net, that I have found When I say go, be ready to throw Go! Throw it on him, not me! Uh, let's try something else
- Now watch and learn, here's the deal You slip and slide on this banana peel Ha ha ha, gasp! what are you doing!?
- ba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba We're Number One Hey! ba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba We're Number One ba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba We're Number One Hey! ba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba We're Number One Hey! Hey!
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement