MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/bg0ghd/deleted_by_user/elp98rc/?context=3
r/badcode • u/[deleted]
[deleted] — view deleted post
13 comments sorted by
View all comments
1
Well, here's my first attempt at one of these.
For extra masochism, it was compiled and run as an MSDOS application using VC++ 1.5 on Win3
#include "iostream.h" #include "string.h" int main() { for(int cl = 0; cl < 200; cl++) { cout << "\n"; } cout << "Welcome to HANGED! - an MS-DOS compatible Hangman you won't miss!\n"; cout << "Insert a word to guess (max. 10 char plz no cheat): "; char word[33]; cin >> word; // truncates the word to the specified 10 chars word[11] = '\0'; int lifes = 8; int rightLetters = 0; short int bigError = 0; loop: cout << "\n||==========\n"; if(lifes < 8 ) cout << "|| | \n"; else cout << "|| \n"; if(lifes < 2 ) cout << "|| | \n"; else if (lifes < 7) cout << "|| O \n"; else cout << "|| \n"; if(lifes < 1 ) cout << "|| X \n"; else if(lifes < 2 ) cout << "|| O \n"; else if (lifes < 6) cout << "|| /|\\ \n"; else cout << "|| \n"; if(lifes < 2 ) cout << "|| /|\\ \n"; else if (lifes < 5) cout << "|| | \n"; else cout << "|| \n"; if(lifes < 2 ) cout << "|| _ | _\n"; else if (lifes < 3) cout << "|| _ / \\ _ \n"; else if (lifes < 4) cout << "|| _ /_\\ _ \n"; else cout << "|| _______ \n"; if(lifes < 2 ) cout << "|| |\\/ \\/|\n"; else if (lifes < 3) cout << "|| |\\ /|\n"; else if(lifes < 4) cout << "|| | |\n"; else cout << "|| | |\n"; cout << "============\n"; if(bigError == 1) goto bigFail; int i; if(rightLetters == strlen(word) ) { goto bigWin; } for( i = 0; i < strlen(word) ;i = i+1) { cout << "\nThe word so far: "; if(i < rightLetters) cout << word[i]; else cout << "*"; } cout << "\nYou have " << lifes << " attempts remaining.\n\n"; cout << "Insert a character: "; char guessedLetter; cin >> guessedLetter; if(word[rightLetters] - guessedLetter != 0) { lifes = lifes -1; } else { rightLetters++; } if(lifes <= 0) { bigError = 1; } goto loop; bigFail: cout << "You lost\n"; goto exit; bigWin: cout << "You won!\n"; exit: return 0; }
View all comments
1
u/ferrango Well it's broken now, and nobody is here to fix it Apr 24 '19
Well, here's my first attempt at one of these.
For extra masochism, it was compiled and run as an MSDOS application using VC++ 1.5 on Win3