我写了一个C++程序,出现了这个错误,我找不到原因。有谁能够帮我。此功能用于从链表中删除第 i 个元素,即使我尽力了,但我找不到原因。
#include <cstdio>
#include <fstream>
using namespace std;
struct node
{
int value;
node * next;
};
typedef struct node list;
list* head = NULL;
int list_length = 0;
bool empty(){
return (head == NULL);
}
void delete(int i){
if(i>list_length) return;
if(empty()) return;
int count = 0;
list* curr = head;
while(curr != NULL && count < i-1){
curr = curr -> next;
count++;
}
list* temp = curr -> next;
curr next = temp -> next;
list_length--;
}
int main(){
}