mew55
  • mew55
C++ thank u ganeshie8 for helping me :D. everything ran great but there one teeny tiny thing i need help on. its the output file. the program created the output for the index location. i need the output file to have not only the index location of a word but also this.
Computer Science
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

mew55
  • mew55
1 Attachment
ganeshie8
  • ganeshie8
you need to add another loop
mew55
  • mew55
how do i add the loop and where do i put it?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

ganeshie8
  • ganeshie8
below statements are not part of loop :- cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; cout << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; cin>> temp;
ganeshie8
  • ganeshie8
you need to put them in a loop.. il modify and post u code wait
mew55
  • mew55
thank u so much
ganeshie8
  • ganeshie8
#include #include #include #include using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } for(k=0; k> temp; idx=-1; for(i=0; i
mew55
  • mew55
no if or else statements?
mew55
  • mew55
oh nvm i c them XD.
ganeshie8
  • ganeshie8
herez the output i see when i execute
1 Attachment
mew55
  • mew55
sorry i frozed for some reason. yeah its good but instead of the welcome, i want the program to go back to the part where i have to type another word.
ganeshie8
  • ganeshie8
like this ?
1 Attachment
mew55
  • mew55
YES YES YES :D!!!
ganeshie8
  • ganeshie8
just move the Welcome line out above the for loop
ganeshie8
  • ganeshie8
#include #include #include #include using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; for(k=0; k> temp; idx=-1; for(i=0; i
mew55
  • mew55
omg u r a life save. thank u so much :D
ganeshie8
  • ganeshie8
yw !
mew55
  • mew55
aaw u dont have to give me a medal. u deserve it :D
mew55
  • mew55
1 Attachment
ganeshie8
  • ganeshie8
u coded very good most part of the working code... thats why i gave u :)
mew55
  • mew55
do i need to put an array or set presion?
ganeshie8
  • ganeshie8
i dint get u... array for wat ?
ganeshie8
  • ganeshie8
u want output file also to have wat..
mew55
  • mew55
oh array is for numbers. but ....let me try again. from the pdf i just attached and on the bottom of the screen, it shows every like wut the command prompt said. here is wut they gave me.
ganeshie8
  • ganeshie8
ok i wait. i dint get wat u saying though.. :(
mew55
  • mew55
when i put outfile to the welcome, the please section, the cin>>temp; the index location, the word not found section, and the quit section, it worked but when i open the output file, its like each section is all in big long sentences
mew55
  • mew55
okay u c the pdf file?
ganeshie8
  • ganeshie8
okie i opened pa13.pdf
mew55
  • mew55
and on the very bottom of the page it shows the output and the output file (notepad)
ganeshie8
  • ganeshie8
yea im there
ganeshie8
  • ganeshie8
oh u saying in ur output file, you not getting this "Please.. " line eh ?
mew55
  • mew55
yes plus the welcome and the word i type
ganeshie8
  • ganeshie8
ok il modify wait
mew55
  • mew55
kk thank u. i hope i am not asking much :S
ganeshie8
  • ganeshie8
output file like this ?
1 Attachment
ganeshie8
  • ganeshie8
if so, modified code :-
ganeshie8
  • ganeshie8
#include #include #include #include using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; outFile<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; for(k=0; k> temp; outFile<< temp << endl; idx=-1; for(i=0; i
mew55
  • mew55
sorry was peeling carrots. and yes
ganeshie8
  • ganeshie8
lol ok i just added two extra lines in this, for outputting the Welcome line and the input entry line.. see if it makes sense
mew55
  • mew55
oh maybe thatz y it wasnt working, i didnt put the endl; in the cin temp of the outfile
ganeshie8
  • ganeshie8
oh ya i did the same and it dint work... and then i corrected...
mew55
  • mew55
kk i am going to test it out now. thank u so much :D
ganeshie8
  • ganeshie8
np just holler if need anything
mew55
  • mew55
kk :D
ganeshie8
  • ganeshie8
?
mew55
  • mew55
sorry. its long XD
ganeshie8
  • ganeshie8
ha ok whtas wrong in helping...
mew55
  • mew55
but she want me to do everything and give her the assignment
mew55
  • mew55
is that bad?
ganeshie8
  • ganeshie8
oh. then it is bad only. but its okay we can be flexible and help each other out right... especially in crunch times... she says she is occupied fully... i would help...
ganeshie8
  • ganeshie8
wat program is it
mew55
  • mew55
and i really appreciate that :3
ganeshie8
  • ganeshie8
oh ok.. then u can give her program and explain it hink... i gotta slp 1 am over here... gn

Looking for something else?

Not the answer you are looking for? Search for more explanations.