// Main4b.cpp // This contains the program for adding and removing words // to the hangman datfile. // Copyright (c) 1998 Forest J. Handford ////////////////////////////////////////////////////////// #include "loadfile.h" // For LoadFile() and headers. #include // For toupper() #include // For strcpy() and strcmp() void WriteWords(); // Prototype // The main function to our editer void main() { LoadFile(); // Load the file ofstream DatFile; //The out file char Answer; //A Y or N value char Word[MAX_WORD_SIZE]; //This will hold a word int Size; //This will hold the strings size int Loop; // This will hold a subscript WriteWords(); cout<>Answer; // Loop to take new words while (toupper(Answer) == 'Y') { cout<<"What word would you like to enter, Please keep it below " <>Word; Size = strlen(Word); // Make the word lower case for(int Loop = 0; Size + 1 > Loop; Loop++) { Word[Loop] = tolower(Word[Loop]); } strcpy(Words[Count++],Word); cout<>Answer; } cout<>Answer; // Loop to remove words while (toupper(Answer) == 'Y') { cout<<"What word do you want to remove? "; cin>>Word; Size = strlen(Word); // Make the word lower case for(int Loop = 0; Loop < Size +1; Loop++) { Word[Loop] = tolower(Word[Loop]); } // Look for the word and if found remove it for (Loop = 0; Loop < Count; Loop++) { // if strings are = remove it if (strcmp(Words[Loop],Word) == 0) { // adjust where the words are and reduce count's size strcpy(Words[Loop],Words[--Count]); strcpy(Words[Count],""); // replace with nothing break; } } cout<>Answer; } DatFile.open("words.dat"); //Open the file //Save the words for(Loop=0; Loop < Count - 1; Loop++) { DatFile< Count) break; DatFile< Count) break; DatFile< Count) break; DatFile< Count) break; DatFile< Count) break; cout< Count) break; cout< Count) break; cout< Count) break; cout<