One letter of a string comparison

Hello everyone,
I have a beginner question, im sure the answer will be a stupid simple thing...

I just would like to turn this into cpp:

1
2
3
4
5
6
7
8
9
10
string eg("azertyFTW");
if(eg[one of the letters contained in this string] == 'c')
{
cout << "eg has the letter c in it";
}

else
{
cout << "not this time :(";
}


Here it is :)
He hope someone has got my answer ;)
Thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <string>
#include <iostream>
using namespace std;

int main()
{  
	string eg("azertyFTW");

	if (eg.find('c') != string::npos)
		cout << "eg has the letter c in it";
	else
		cout << "not this time :(";

	return 0;
}
Thank you!! The "problem" is that i dont know what ::npos or .find('c') mean, but its not important... Thank you ;)
Last edited on
@ajh32 no it won't help because you just did his homework for him :) That's why we try not to give people straight answers to questions.
Topic archived. No new replies allowed.