다음 코드를 고려 작동하지 않는 함수의 반환 값 사용 : 임시 변수에 비교하기 전에 수학 계산의 결과를 저장하는 데 필요한 이유 코멘트가 나타으로는 C++ 수학 비교
char foo[32] = "123456";
printf("strlen(foo) = %d\n", strlen(foo));
if ((5 - strlen(foo)) > 0)
{
//This statement prints because the comparison above returns true, why?
printf("String must be less than 5 characters, test 1\n");
}
int tmp;
if ((tmp = 5-strlen(foo)) > 0)
{
//This statement does not print and makes since
printf("String must be less than 5 characters, test 2\n");
}
을, 이해가 안 돼요 또 다른 가치있는 일.
입니다. '% d'은 (는) '% zu'여야합니다. – chris