求助 C 编译错误: stack around the variable 'a' was co rrupted ……如附件中所示!
程序代码:
#include< stdio.h > struct node{ long num; struct node *next; }; void main( ) { struct node a[ 10 ]; int i; int j; int m; //声明函数 void Insert( struct node *head, struct node *no); //初始化 for( m = 1; m < 11; m++ ) { a[ m ].num = 0; a[ m ].next = NULL; } //更新 for ( i= 1; i < 11; i ++ ) { for( j = 1; j < 1000; j ++ ) { struct node no, *head; no.num =j; no.next = NULL; head = &a[ i ]; Insert( head, &no ); printf( "%d\t", j ); if( j == 20 ) printf( "\n" ); } } }; void Insert( struct node *head, struct node *no ) { struct node *p0, *p1, *p2; p1 = head; p0 = no; if ( head -> next == NULL ) { head = p0; p0 -> next = NULL; } else { while( ( p0 -> num > p1 -> num ) && ( p1 -> next != NULL ) ) { p2 = p1; p1 = p1 -> next; } if( p0 -> num <= p1 -> num ) { if( head == p1 ) { head = p0; } else { p2 -> next = p0; } p0 -> next = p1; } else { p1 -> next = p0; p0 -> next = NULL; } } } [local]1[/local]