프로그램에서 작업하고 있는데 "dosell '에 대한 정의되지 않은 참조가 계속 발생하며 어떤 일이 일어나는지 알 수 없습니다. 다음은 함수의 선언은 다음과 같습니다계속 ... "정의되지 않은 참조 ..."
void dosell(int *cash, int *numchips);
함수의 사용 :의 시작 부분에 함수의 선언을 넣어
void dosell(int *cash, int *numchips) {
int numsell;
// Determine the number of chips to be sold.
printf("How many chips do you want to sell?\n");
scanf("%d", &numsell);
// Print out the error message if this is too much.
if (numsell > *numchips)
printf("Sorry, you do not have that many chips. No chips sold.\n");
// Execute the transaction.
else {
(*cash) += sellchips(numsell);
(*numchips) -= numsell;
}}}
'void dosell (int * cash, int * numchips)'선언 또는 정의 ** ABOVE ** 'else if (choice == 2) ... dosell (& 현금, numchips); ? –
'dosell()'은 호출과 같은 파일에 있습니까? 그렇지 않다면 프로그램을 만들기 위해 파일을 모두 (모두) 연결하고 있습니까? 마지막에는'}}} '과 함께 무엇이 있는가? 실수로 GCC 확장 - 중첩 된 함수를 사용하지 않는 한 구문 오류와 유사합니다. 정확한 오류 메시지를 표시 할 수 있습니까? 링커 오류 또는 컴파일러 오류입니까? –
이것은 링커 오류입니다. 링커는'dosell()'의 정의/구현을 제공하는 객체를 놓친다. 그래서 prototyping, 선언은 여기에 문제가되지 않습니다, 친애하는 동료 commenters, 그 후자의 개조로 진정 컴파일러 전용. – alk