void main()으로 main 함수의 반환값을 void로 선언하셨기 때문입니다.
보통 프로그램이 정상적으로 종료되면 EXIT_SUCCESS(0)를, 정상적으로 종료되지 않으면 EXIT_FAILURE(1)을 반환하는데, 채점 프로그램에서 런타임 에러가 났느냐 안 났느냐를 판단할 때, main 함수의 반환값을 기준으로 판단하는 것으로 알고 있습니다.
C++이나 C99/C11에서는 main 함수에서 사용자가 별도로 return 문을 정의하지 않으면 자동으로 return 0;를 하도록 만들어서 프로그램을 정상적으로 종료할 수 있도록 해줍니다.
main 함수와 main 함수에서의 return value에 대한 설명은 아래에 나와있으니 참고하시길 바랍니다.
결론을 말하면 void main() 대신에 int main()이라고 선언하시길 바랍니다.
In C++ and C99/C11, without a return statement in main function, it's default to return 0;
§ 3.6.1 Main function
A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0;
also read wiki page C/C++ main function
In case a return value is not defined by the programmer, an implicit return 0; at the end of the main() function is inserted by the compiler; this behavior is required by the C++ standard.
ehe1021 7년 전