If statement

How can I correct the error ..

$ g++ -op p.cpp
p.cpp: In function ‘int main()’:
p.cpp:13:20: error: no match for ‘operator&&’ (operand types are ‘char’ and ‘std::basic_string<char>’)
if ((n=1)&&((a='a')&&(c="cc")))
^
p.cpp:13:20: note: candidate is:
p.cpp:13:20: note: operator&&(bool, bool) <built-in>
p.cpp:13:20: note: no known conversion for argument 2 from ‘std::basic_string<char>’ to ‘bool’




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
#include<iostream>
#include<cstring>
using namespace std;
int main()
{

int n;
string c ;
char a;
cout<<"ENter number ,and two words"<<endl;
cin>>n>>a>>c;

if ((n=1)&&((a='a')&&(c="cc")))
{
 cout<<"test"<<endl;
}
return 0;
}
Line 14: You want the comparison operator (==), not the assignment operator (=).
Thanks..
Topic archived. No new replies allowed.