본문 바로가기
카테고리 없음

[C/C++] 조건문에서 연산자 주의

by 일사만루병살 2011. 1. 26.
#include <iostream>
using namespace std;
int main()
{
int i=200;
cout<<" i가 300이냐?";
if(i==300)
cout<<"true\n";
else
cout<<"false\n";

cout<<" i가 300이냐?";
if(i=300)                      // 변수 i에 300을 대입 했기 때문에 true가 뜬다.
cout<<"true\n";
else
cout<<"false\n";

}