dont know exactly how to do program and tried to copy from another program and didnt work

#include <iostream>
#include <cstring>
using namespace std;

int s;

int count(const char string &s, char a)
{
int a;
int startingIndex = 0;
int remainingLength = s;
while (startingIndex <= remainingLength)
{


bool matched = true;
for (int i = 0; i < string &s; i++)
{
if (s = a)

{
startingIndex++;
remainingLength--;
matched = false;
}
}

if (matched) return startingIndex;
}

return 0;
}

int main()
{
// Prompt the user to enter a string
cout << "Enter the word: ";
char s[Welcome];
cin.getline(s, Welcome);
// Prompt the user to enter a string
cout << "Enter the letter: ";
char a[e];
cin.getline(a,e );

cout << count(string &s, char a) << endl;

return 0;
}




any help would be greatly appreciated
First, I'm assuming you once had some variable named Welcome. You can't use it to declare an array's size, for while some compilers support it as an extension, it's not exactly legal in the current C++.

Second, I'd suggest maybe using std::strings rather than char[]s. There are a lot of benefits. :)

Third, what were you trying to do here? const char string &s

Fourth, in your count function you have an int and a char both of which are named a. Fix!

Finally, there may be more issues but I won't look into them until you use [code] tags.

Happy coding!

-Albatross
here are tutorials on how to make an array and use array of characters:
http://www.cplusplus.com/doc/tutorial/arrays/
http://www.cplusplus.com/doc/tutorial/ntcs/

and it would help a lot if you care to explain what your program is trying to achieve
Um, what? First please encode your source with the [code][ /code] tags. Also please tell us what the problem(s)/error(s) are.
Last edited on
Topic archived. No new replies allowed.