Home > Back-end >  The debug an assertion failed
The debug an assertion failed

Time:09-25

This program is simple to use the list of applications, but compile appeared after the operation, the debug an assertion failed error, I saw on the Internet everyone said there are wild pointer will appear this kind of situation, beginner, don't know how to find, have a great god gives directions how to find wild pointer? Thank you for




/* programming ideas - & gt; To simplify the modification process */
/* use structure list */
/* through input to determine the number of input, when the movie name is an empty row, enter stop */
#include
#include /* malloc () function prototype */
#include /* provide strcpy () function prototype */
# define TSIZE 45/* deposit title array size */
Struct film {
Char title [TSIZE];
Int rating;
Struct film * next;/* points to a structure under the list of */
};

Int main (void)
{
Struct film * head=NULL;
Struct film * prev=NULL;
Struct film * current=NULL;
Char input [TSIZE];

/* */collect and store information
Puts (" Enter first movie title: ");
While (gets (input)!=NULL & amp; & Input [0]!='\ 0')
{
The current=(struct film *) malloc (sizeof (struct film));
If (head==NULL)/* */first construction
The head=current;
The else/* * the following structure/
Prev - & gt; Next=current;
Current - & gt; Next=NULL;
Strcpy (current - & gt; The title, input);
Puts (" Enter your rating & lt; 0 to 10 & gt;" );
The scanf (" % d ", & amp; Current - & gt; Rating);
While (getchar ()! )
='\ n'continue;
Puts (" Enter next movie title (empty line to stop) : ");
Prev=current;
}

/* give movie list */
If (head==NULL)
Printf (" No data rose. ");
The else
Printf (" Here is the movie list: \ n ");
The current=head;
While (current!=NULL)
{
Printf (" Rating Movie: % s: % d. \ n ", current - & gt; The title, the current - & gt; Rating);
The current=current - & gt; Next;
}

*//* task has been completed, release space
The current=head;
While (current!=NULL)
{
Free (current);
The current=current - & gt; Next;
}
Printf (" Bye! \n");
return 0;

}
  • Related