Home > Back-end >  VS access conflict, the normal operation of VC (ball ball bosses see!)
VS access conflict, the normal operation of VC (ball ball bosses see!)

Time:09-20


Can also run before morning, don't know why suddenly error, nothing
Breakpoint debugging, found the character array are all hot
Once when the input string is error,
Try the VC, almost all of the code, VC can run normally
Of course change the scanf for scanf_s
Is my structure pointer with wrong? But not two software can be a no good


 
#include
#include

# define MAX 100

//book structure
Struct the Book
{
Char book_name [30].
Unsigned int book_id;
Double book_price;
};

//ShuLu structure
Struct library
{
Struct Book book_array (MAX);
Unsigned int book_num;
};

//display menu
Void show_menu that demonstrates ()
{
Printf (" SSSSSSSSSSSSSSSSSSSSSSSSSSS \ n ");
Printf (" \ n ");
Printf (" book supermarket management system v1.0 \ n ");
Printf (" 1. The basic information management books \ n ");
Printf (" 2. Book settlement processing \ n ");
Printf (" 3. The historical record books \ n ");
Printf (" 0. Exit system \ n ");
Printf (" \ n ");
Printf (" EEEEEEEEEEEEEEEEEEEEEEEEEEE \ n ");
}

//add books
Void add_book (struct library * lib)
{
If (lib - & gt; Book_num & gt;=MAX)
{
Printf (" the number of books has reached its maximum value, \ n ");
system("pause");
system("cls");
return;
}
The fflush (stdin);
Printf (" please enter the name of the book: \ n ");
Scanf_s (" % s ", lib - & gt; Book_array [lib - & gt; book_num] book_name);
Printf (" please enter the ID of the book: \ n ");
Ud scanf_s (" % ", & amp; Lib - & gt; Book_array [lib - & gt; book_num] book_id);
Printf (" please input the price of the book: \ n ");
Lf scanf_s (" % ", & amp; Lib - & gt; Book_array [lib - & gt; book_num] book_price);
Lib - & gt; Book_num + +;
Printf (" add success! \n");
system("pause");
system("cls");
}

//display books
Void show_book (struct library * lib)
{
If (lib - & gt; Book_num==0)
{
Printf (" the current record is empty, \ n ");
system("pause");
system("cls");
return;
}
int i=0;
Printf (" title \ dar \ t price \ n ");
For (I=0; i {
Printf (" % s \ t % u \ t % 2 lf \ n ", lib - & gt; Book_array [I]. Book_name, lib - & gt; Book_array [I]. Book_id, lib - & gt; Book_array [I] book_price);
}
system("pause");
system("cls");
}

//position find books
Int find_book (struct library * lib)
{
}

Basic information management//books
Void book_management (struct library * lib)
{
Int choise.
system("cls");
While (1)
{
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * books basic information management \ n ");
Printf (" * * 1. Add books \ n ");
Printf (" * * 2. Delete books \ n ");
Printf (" * * 3. Modify the books \ n ");
Printf (" * * 4. Look for books \ n ");
Printf (" * * 5. Show books \ n ");
Printf (" * * 0. Exit function \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Scanf_s (" % d ", & amp; Choise);
The switch (choise)
{
Case 1:
Add_book (lib);
break;
Case 2:
break;
Case 3:
break;
Case 4:
break;
Case 5:
Show_book (lib);
break;
Case 0:
return;
Default:
Printf (" input error, please choose again! \n");
system("pause");
break;
}
system("cls");
}
}

Int main ()
{
Int choise.
Struct library lib.
Lib. Book_num=0;
System (" color f0 ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * \ n ");
Printf (" * welcome to use the supermarket management system! * \ n ");
Printf (" * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
system("pause");
system("cls");
While (1)
{
Show_menu that demonstrates ();
Scanf_s (" % d ", & amp; Choise);
The switch (choise)
{
Case 1:
Book_management (& amp; Lib);
break;
Case 2:
break;
Case 3:
break;
Case 0:
return 0;
Default:
Printf (" input error, please choose again!" );
system("pause");
break;
}
system("cls");
}
}

CodePudding user response:

0 xc0000005 mostly cross-border or visit the unallocated address pointer,
Character array is all hot, because no initialization arrays, structure after the application,
That need to be
memset

CodePudding user response:

 # include & lt; Stdio. H> 
#include
//# include & lt; Windows. H>

# define MAX 100

//book structure
Struct the Book
{
Char book_name [30].
Unsigned int book_id;
Double book_price;
};

//ShuLu structure
Struct library
{
Struct Book book_array (MAX);
Unsigned int book_num;
};

//display menu
Void show_menu that demonstrates ()
{
Printf (" SSSSSSSSSSSSSSSSSSSSSSSSSSS \ n ");
Printf (" \ n ");
Printf (" book supermarket management system v1.0 \ n ");
Printf (" 1. The basic information management books \ n ");
Printf (" 2. Book settlement processing \ n ");
Printf (" 3. The historical record books \ n ");
Printf (" 0. Exit system \ n ");
Printf (" \ n ");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related