Come someone please tell me what I am doing wrong as to why I cannot get this to
ID: 3646384 • Letter: C
Question
Come someone please tell me what I am doing wrong as to why I cannot get this to compile?Here is my code:
#include <iostream>
#include <string>
using namespace std;
// Function Prototype
int CountCharacters (string);
// Main
int main()
{
string String1; //Holds string
int count; // Holds the number of characters
cout << "Enter String";
cin >> String1;
count = CountCharacters (String1);
// Outputs returned value
cout << "Number of characters in string is: ";
cout << count;
system ("pause")
}
// Function Defention
int CountCharacters(string str)
{
// Variable declaration
int count = 0;
int i = 0;
while (str[i] != '')
{
count++;
i++;
}
return count;
}
Explanation / Answer
please rate-thanks
you are missing a ; after system("pause");
#include <iostream>
#include <string>
using namespace std;
// Function Prototype
int CountCharacters (string);
// Main
int main()
{
string String1; //Holds string
int count; // Holds the number of characters
cout << "Enter String";
cin >> String1;
count = CountCharacters (String1);
// Outputs returned value
cout << "Number of characters in string is: ";
cout << count;
system ("pause");
}
// Function Defention
int CountCharacters(string str)
{
// Variable declaration
int count = 0;
int i = 0;
while (str[i] != '')
{
count++;
i++;
}
return count;
}