HOw come I am getting some weird output when I go and compile it?
Code:int main() { char c, ch, ch1, ch2; string word; string word1; //char word[50]; //char word1[25]; int length, i, next_guess, num_letters, m, x; do { do { cout<<"\n\n\n\t******************************************************************\n"; cout<<"\t******************* PrOgRaMmInG VoCaB GuEsSeR ********************\n"; cout<<"\t******************************************************************\n\n\n"; cout<<"\n\t(S) Start the Game\n\n\t(Q) Quit\n\n\n\t Enter your choice: "; cin>> ch2; }while (ch2 != 's' && ch2 != 'S' && ch2 != 'Q' && ch2 != 'q'); if (ch2 == 'Q' || ch2=='q') exit (0); if (ch2 == 's' || ch2=='S') { ifstream fin("words.txt"); if (!fin) { cout<<"\n\nYou are missing a file called words.txt\n\n"; return 0; } for (i=0;!fin.eof();i++) getline(fin, word);//fin.getline(word,25); fin.close(); do { x=rand(); }while(x>i || x<0); ifstream finn("words.txt"); for (i=0;!finn.eof();i++) {finn>>c; getline(finn,word)/*finn.getline(word,25)*/; if (x==i) break;} finn.close(); } if (ch2 == 'S' || ch2=='s') { length = word.length(); /*length=strlen(word);*/ //Computes the length of the string char choosen[50]="\0"; num_letters=0; m=0; for (i=0; i<=24; i++) { if (word[i]=='\0') {word1[i]='\0'; break;} if (word[i]==' ') {word1[i]=' '; num_letters++;} if (word[i]!=' ') word1[i]='-'; } next_guess=length+2-num_letters; //Number of Guesses Left do { definition: define_word(c); if (m!=0) cout<<"\n\n\t\t\tChoosen letters : "<<choosen<<"\n"; cout<<"\n\n\n\t\t\t "<<word1; cout<<"\n\n\n\tYou have "<<next_guess<< " guesses left, choose a letter : "; cin>>ch; cin.get(); for (i=0;i<25;i++) if (choosen[i]==ch) { cout<<"You have choosen "<< ch <<" already!!\n"; goto definition; } next_guess--; choosen [m]=ch; choosen [m+1]=','; m+=2; for (i=0;i<=49;i++) if (word[i]==ch || word[i]==ch+32 || word[i]==ch-32) word1[i]=ch; if (word==word1)//(!strcmpi (word1,word)) { cout<<"\n\t\t\t "<<word;//strupr(word); cout<<"\n\n\t\t\tCongratulations, You have won!\n"; break; } }while(next_guess>0 || word==word1/*!strcmpi (word1,word)*/); if (word1==word)/*(strcmpi (word1,word)) */ cout<<"\n\tBETTER LUCK NEXT TIME.\n\n\tTHE WORD IS : "<</*strupr*//*(*/word/*)*/<<endl; } cout<<"\nWould you like to play again? [Y or N] : "; cin>>ch1; cin.get(); }while (ch1=='y' || ch1=='Y'); system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks


