| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 493 人关注过本帖
标题:很小的问题,求助、谢谢
只看楼主 加入收藏
NordicNavy
Rank: 1
来 自:地球
等 级:新手上路
帖 子:30
专家分:0
注 册:2008-10-20
收藏
 问题点数:0 回复次数:2 
很小的问题,求助、谢谢
C 的初级水平,所以问题可能很简单,但就是不知如何解决。
问题我写在程序注释里了。。
#include <stdio.h>
#include <stdlib.h>

struct CD
       {
       char name[20];
       char description[40];
       char category[12];
       float cost;
       int number;
       }/*disc={"Best Hits",
                    "Pop crazy music",
                    "POP MUSIC",
                    24.99, 21
                    }*/
       disc;
main()
      {
      puts("Enter disc information\n\n");
      printf("Enter the name:\n");
      gets(disc.name);
      printf("Enter the description:\n");
      gets(disc.description);
      printf("Enter the category:\n");
      gets(disc.category);
      printf("Enter the price:\n");
      scanf("%f", &disc.cost);
      printf("Enter the location:\n");
      scanf("%d", &disc.number);
     /*问题在于程序运行到这里,就自动关闭,好像我的问题大多是此类的*/
      puts("The information on the CD is:\n\n");
      printf("Name          %s\n", disc.name);
      printf("Description   %s\n", disc.description);
      printf("Category      %s\n", disc.category);
      printf("Price         %.2f\n", disc.cost);
      printf("Location      %d\n", disc.number);
      
      }
搜索更多相关主题的帖子: category include music number Enter 
2008-10-22 04:15
leebico
Rank: 1
来 自:湘
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-10-21
收藏
得分:0 
#include <stdio.h>
#include <stdlib.h>

struct CD
       {
       char name[20];
       char description[40];
       char category[12];
       float cost;
       int number;
       }/*disc={"Best Hits",
                    "Pop crazy music",
                    "POP MUSIC",
                    24.99, 21
                    }*/
       disc;
main()
      {
      puts("Enter disc information\n\n");
      printf("Enter the name:\n");
      gets(disc.name);
      printf("Enter the description:\n");
      gets(disc.description);
      printf("Enter the category:\n");
      gets(disc.category);
      printf("Enter the price:\n");
      scanf("%f", &disc.cost);
      printf("Enter the location:\n");
      scanf("%d", &disc.number);
     /*问题在于程序运行到这里,就自动关闭,好像我的问题大多是此类的*/
      puts("The information on the CD is:\n");
      printf("Name          %s\n", disc.name);
      printf("Description   %s\n", disc.description);
      printf("Category      %s\n", disc.category);
      printf("Price         %.2f\n", disc.cost);
      printf("Location      %d\n", disc.number); getch();
      
      }

程序最后加一个getch()试试,我已测试可以运行出来

未命名.jpg (13.72 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2008-10-22 09:12
leebico
Rank: 1
来 自:湘
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-10-21
收藏
得分:0 
你说大多是此类情况,可能也是缺少那个
2008-10-22 09:14
快速回复:很小的问题,求助、谢谢
数据加载中...
 
   



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

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