我写了一个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(){
}
Run Code Online (Sandbox Code Playgroud)