#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if(argc != 2)
return 1;
if(!atoi(argv[1]))
printf("Error.");
else printf("Success.");
return 0;
}
내 코드는 0 값 아래 또는 위에있는 인수를 입력 할 때 작동합니다.문자열이 0 일 때 atoi를 사용합니까?
[[email protected] programming]$ ./testx 1
Success.
[[email protected] programming]$ ./testx -1
Success.
[[email protected] programming]$ ./testx 0
Error.
왜 작동하지 않습니까?
어떻게 작동하지 않습니까? '(! 0)'이 참입니다. 유일한 문제는 "atoi returns 0"의 철자가 잘못되었다는 것입니다. –