1
我在Visual Studio 2013寫了下面的C程序:未處理的異常
#include <stdio.h>
int main(){
int number;
int fibonacci(int number);
printf("please enter number\n");
scanf_s("%d", &number);
printf(fibonacci(number));
return 0;
}
int fibonacci(number){
if (number == 1 || number == 0){
return number;
}
else{
return fibonacci(number - 1) + fibonacci(number - 2);
}
}
它給我這個錯誤:
Unhandled exception at 0x5867F365 (msvcr120d.dll) in Project7.exe: 0xC0000005: Access violation reading location 0x00000002.
我覺得這是對廢棄一個空指針。我如何解決它?
感謝ü非常bolov.I是粗心,那是我mistake.Now我的代碼works.I've花了幾個小時在那個簡單的錯誤 – Wardruna