Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, this is my c++ code and I am confused on how to fix this error in my code an

ID: 3790811 • Letter: H

Question

Hi, this is my c++ code and I am confused on how to fix this error in my code and I'm curious if it's an easy solution or is it a fundemental problem with my code. Thank You!

And I get this error.

EDIT: I ended up figuring out how to fix the code (by changing the "string" type to an "int" type in the function), but is there anyway to reduce the "int main()" function down to just one line? Or am I going to have to have those two variables delcared int he main function for my program to work?

EDIT: Actually, at this moment, the program will only run once. As I type in "g++ Dubois,ChristopherHW3.cpp" and press enter; it'll be fine. But as I go into type "./a.exe"---no characters come up and Cygwin seems to "Freeze" up and I have to exit Cygwin in order to run the program again. Any reason for this?

EDIT: Here is the code. I figured the images would be enough

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int first_and_only_function(string Entered_Word, string Another_Word)
   {
  
   vector <string> NumberofWords;
   string Key_Word_Needed = "*endl*";
   int word_count = 0;
   int Number_Of_Times = 0;
   string new_Entered_Word;
   string New_Another_Word;
   while(true)
   {
   cout<<"Please Enter a search word (Terminating word is '*endl*'. ";
  
   getline(cin,new_Entered_Word);
  
  
       if ((Key_Word_Needed.compare(new_Entered_Word)==0))
       {
           break;
       }
       NumberofWords.push_back(new_Entered_Word);
       word_count++;
   }
       cout<<"The amount of tries were: "<<word_count+1 << "(including correct search word) ";
cout<<"Let's find the number of times the word you'd like to find comes up! ";
   cout<<"So, if you wanted to find out how many times 'bear' came up, just type in 'bear' again to see. ";
  
   getline(cin,New_Another_Word);
   for(int i=0; i<=word_count;i++)
   {
       if(NumberofWords[i].compare(New_Another_Word)==0)
       {
       Number_Of_Times++;
       }
   }
   cout<<"The word came up:"<<Number_Of_Times<<" times in the list. ";
return(0);
   }
int main()
{
   string Entered_Word;
   string Another_Word;
   first_and_only_function(Entered_Word, Another_Word);
//   return(0);
}

#include kiostream> 3 #include 4 #include Kvector 5 using name space std; 6 string first and only function (string Entered Word, string Another Word) vector string> NumberofWords string Key Word Needed endl 10 11 int word count 0; int Number of Times 0 12 string new Entered Word; 14 string New Another Word; 15 while (true) 16 cout

Explanation / Answer

for (i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote