| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 630 人关注过本帖
标题:求助 C 编译错误: stack around the variable 'a' was co rrupted ……如附 ...
取消只看楼主 加入收藏
hujianquan
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-5-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求助 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]
搜索更多相关主题的帖子: around color 
2014-05-27 00:44
hujianquan
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-5-27
收藏
得分:0 
回复 3 楼 忘了 _ 这一切
谢谢老师,是这样的!
2014-05-27 12:29
快速回复:求助 C 编译错误: stack around the variable 'a' was co rrupted …… ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031712 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved