about VS2019 Debugging problems : The process has exited , Code is -1073741819( resolved )
details : In the last article, I posted the problem of this process , After I read it 《c Language programming fourth edition 》 and 《 Algorithm and data structure 》 The two books finally found a solution by comparing the code and debugging
resolvent :
First find the source file of the project and right-click to find the properties
Then select exclude from build !
Rebuild solution , Code problems found :
Previous code :
#include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <string.h>
// Create linked list struct linknode { int data; struct linknode* next; }; // Initialize linked list -> Create an empty linked list
struct linknode* init_list() { // Create header node struct linknode* head = malloc(sizeof(
struct linknode)); head->data = 0; head->next = NULL; // Create tail node struct linknode* p
= head; // Get user input int nodedata = 0; while (1) { printf(" Please enter a value ( Input equals 0 Value exit ):");
scanf_s("%d", &nodedata); if (nodedata == 0) { break; } // Create a new node struct linknode*
newnode= malloc(sizeof(struct linknode)); newnode->data = nodedata; newnode->
next= NULL; // Insert the new node into the linked list p->next = newnode; // Update tail pointer p = newnode; } return head;
// Returning the header node returns the list } // stay old_data Insert a value after the value new_data value ( A new node is concatenated behind the original node ) void addlist(struct
linknode* head, int old_data, int new_data); // Delete data void dellist(struct
linknode* head, int deldata); // Traversal print linked list void showlist(struct linknode* head) {
/*if (head == NULL) { return; }*/ struct linknode* p = head->next;
// Create a tail node to point to the address field of the first short node while (p != NULL) { printf("%d", p->data); p = p->next; }
} // Empty linked list void clearlist(struct linknode* head); // Destroy linked list void destory_list(struct
linknode* head); int main() { struct linknode *head = init_list(); showlist(&
head); return 0; }
After modification of the reference book :
#include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <string.h>
#define LEN sizeof(struct linknode) // Create linked list struct linknode { int data; struct
linknode* next; }; // Initialize linked list -> Create an empty linked list struct linknode* init_list() { // Create header node
struct linknode* head =(struct linknode*) malloc(LEN); head->data = 0; head->
next= NULL; // Create tail node struct linknode* p = head; // Get user input int nodedata = 0; while
(1) { printf(" Please enter a value ( Input equals 0 Value exit ):"); scanf_s("%d", &nodedata); if (nodedata == 0) {
break; } // Create a new node struct linknode* newnode = (struct linknode*)malloc(LEN);
newnode->data = nodedata; newnode->next = NULL; // Insert the new node into the linked list p->next = newnode;
// Update tail pointer p = newnode; } return head;// Returning the header node returns the list }
// stay old_data Insert a value after the value new_data value ( A new node is concatenated behind the original node ) void addlist(struct linknode* head
, int old_data, int new_data); // Delete data void dellist(struct linknode* head, int
deldata); // Traversal print linked list void showlist(struct linknode* head) { /*if (head == NULL) {
return; }*/ struct linknode* p = head->next;// Create a tail node to point to the address field of the first short node while (p !=
NULL) { printf("%d\t", p->data); p = p->next; } } // Empty linked list void clearlist(struct
linknode* head); // Destroy linked list void destory_list(struct linknode* head); int main() {
struct linknode* head = init_list(); showlist(head); return 0; }
Macro definition added
Modified
struct linknode* newnode = (struct linknode*)malloc(LEN);
Finally, we save the changes , remove c Import the file again c File or restart VS2019, debugging !
success :
Technology