首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c 输出有关问题(急)

2012-02-22 
c 输出问题(急!!!)#includestdio.h structstudent{intnumberstructstudent*leftchild,*rightchild}/*

c 输出问题(急!!!)
#include   "stdio.h "
struct   student
{
        int   number;
        struct   student   *leftchild,*rightchild;
};

/*     创建二叉树       */

struct   student   *   IniTree()
{
      struct   student   *p;
      int   i;
      if((p=(struct   student   *)malloc(sizeof(struct   student)))   ==   NULL)
      {
            printf( "分配空间失败!!! ");
            exit(0);
      }
      printf( "\n   Input   Number: ");
      scanf( "   %d   \n ",&i);
      p-> number=i;
      p-> leftchild   =   NULL;
      p-> rightchild   =NULL;
      return   p;
}
main()
{
      struct   student   *head;
      head   =IniTree();
      printf( "\n   Node   Value:   %d ",head-> number);
}

为什么我要输入两个数值后才能退出程序!!!!谢谢

[解决办法]
去掉 "\n "
scanf( " %d ",&i);

热点排行