Question: #include //Including for #include //Including for numeric_limits #include using namespace std; //Function for counting characters inside given string and returning the count int CountCharacters(char userChar,

#include //Including for #include //Including for numeric_limits #include using namespace std; //Function for counting characters inside given string and returning the count int CountCharacters(char userChar, string userString){ //Declaring i and count=0 int i,count=0; //For loop for iterating over each character of userString for(i=0;i //If the userChar is equal to the character at ith position then increment count value by 1 if(userChar==userString.at(i)){ count++; } } //Returning count value return count; }

int main() { //Declaring userChar variable char userChar; //Declaring characterCount variable int characterCount; //Declaring userString variable string userString; //flushing out enter key press to be stored into the //userString as a character, if enter key stored in userString then it will //not give desired output cin.ignore(numeric_limits::max(),' '); //Inputing string getline(cin, userString); //Calling character count function with two parameters userChar and userString characterCount = CountCharacters(userChar, userString); //Printing characterCount cout< return 0; }

Error on above question, please correct my error

main.cpp: In function int CountCharacters(char, std::string): main.cpp:15:13: warning: comparison of integer expressions of different signedness: int and std::__cxx11::basic_string::size_type {aka long unsigned int} [-Wsign-compare] 15 | for(i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!