#include <iostream>
// Demonstration
//
void Demonstration()
{
std::cout << In Demonstration Function n ;
}
// main
// DemonstrationFunction
//
int main()
{
std::cout << "In mainn";
DemonstrationFunction();
std::cout << "Back in main"n ;
return 0;
}
이게 교재에 써있어서 그대로 적었는데..
--------------------Configuration: 2Days5 - Win32 Debug--------------------
Compiling...
2Days5.cpp
2Days5.cpp(7) : error C2065: 'In' : undeclared identifier
2Days5.cpp(7) : error C2146: syntax error : missing ';' before identifier 'Demonstration'
2Days5.cpp(7) : error C2017: illegal escape sequence
2Days5.cpp(7) : error C2146: syntax error : missing ';' before identifier 'Function'
2Days5.cpp(7) : warning C4551: function call missing argument list
2Days5.cpp(7) : error C2065: 'Function' : undeclared identifier
2Days5.cpp(7) : error C2146: syntax error : missing ';' before identifier 'n'
2Days5.cpp(7) : error C2065: 'n' : undeclared identifier
2Days5.cpp(16) : error C2065: 'DemonstrationFunction' : undeclared identifier
2Days5.cpp(17) : error C2017: illegal escape sequence
2Days5.cpp(17) : error C2146: syntax error : missing ';' before identifier 'n'
Error executing cl.exe.
2Days5.exe - 10 error(s), 1 warning(s)
뭐 이런 오류가 납니다..T.T 데체 뭐가틀린거죠?
디버그에 있는 내용을 잘 보세요.()안에 있는 숫자는 에러가 난 줄을 의미합니다. 7번째 줄과 16번째줄, 그리고 17번째 줄에서 에러가 발생되었죠.
비쥬얼 스튜디오에서는 디버깅후 F4를 누르면 에러가 난 해당 줄로 이동해주는 기능도 있으니 이 기능을 잘 활용해보시구요..
한번 스스로의 힘으로 찾아보세요.
이래도 모르시겠다면
7번째줄에서
std::cout << In Demonstration Function n ;(X)
std::cout << "In Demonstration Function n" ;(O)
13번째 줄에서
DemonstrationFunction(); (X)
Demonstration(); (O)
14번째 줄에서
std::cout << "Back in main"n ;(X)
std::cout << "Back in mainn" ;(O)
7번째와 14번째는 스트링으로 "으로 싸줘야 할 부분을 틀리셔서 에러가 난거구요
13번째 줄은 함수이름뒤에 Function이 추가로 들어가버렸네요. 함수를 호출할때는 선언한 함수 이름으로만 해줘야 합니다.