help me i'm a beginner

Help me to resolve this code.

The purpose of this program is that the user types a letter until he finds the good letter chosen by the program with the while buckle(loop).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #include <iostream>

using namespace std;

int main()

{   char (c='d');

    cout << "Entrez un caractère" << endl;
    cin  >> (c='d');

    while (c='d');
    {
    cout << "Vous n'avez pas entré le bon caractère \n";
    cout << "Veuillez réessayer";
    cin  >> char (c='d');
    }

    cout << " Bravo, vous avez entrez le bon caractère" << endl;

    return 0;

    system("PAUSE");
}
char c = 'd';
cin >> c;
while (c == 'd') you cant use a assignment operator for comparison

Last edited on
Its kinda hard to understand the code. You probably mean this - char c = 'd'

But then you want to change c? hmm...

Im guessing you want something like this -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
char c = 'd';
	char u;
	cout << "Entrez un caractère" << endl;
	cin >> u;


	while (u != c)
	{
		cout << "Vous n'avez pas entré le bon caractère \n";
		cout << "Veuillez réessayer";

		cin >> u;
	}
	

	cout << " Bravo, vous avez entrez le bon caractère" << endl;
Topic archived. No new replies allowed.