| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 793 人关注过本帖
标题:第62行 return; 的返回值是什么?
只看楼主 加入收藏
csz9981
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2013-5-16
结帖率:0
收藏
已结贴  问题点数:10 回复次数:2 
第62行 return; 的返回值是什么?
第62行 return; 的返回值是什么?

#include"stdio.h"
#include<string.h>
#define MAX 10
 
struct inv{
    char item[30];
    float cost;
    int onhand;
}inv_info[MAX];

void init_list(),list(),delete(),enter();
int jishu();

main()
{
    char choice;
    init_list();   
    for(;;){
        choice=menu_select();
        switch(choice){
            case 1:enter();break;
            case 2:delete();break;
            case 3:list();break;
            case 4:exit(0);            
        }
    }
}

void init_list()
{
    register int t;
    for(t;t<MAX;t++)
    {
        inv_info[t].item[0]='\0';
    }
}

menu_select()
{
    char s[80];
    int c;   
    printf("1.Enter a item.\n");
    printf("2.Delete a item.\n");
    printf("3.List the inventory.\n");
    printf("4.Quit.\n");
   
    do{
        printf("\nEnter your choice:\n");
        gets(s);
        c=atoi(s);//选取有效整数
    }while(c<0||c>4);
    return c;
}

void enter()
{
    int slot;
    slot=find_free();
    if(slot==-1)
    {
        printf("\nlist full");
        return;                    //返回值是什么,返回到哪里去了?作用是什么?
    }
    printf("enter item:");
    gets(inv_info[slot].item);
    printf("enter cost:");
    scanf("%f",&inv_info[slot].cost);
    printf("enter onhand:");
    scanf("%d%*c",&inv_info[slot].onhand);
}

find_free()
{
    register int t;
    for(t=0;inv_info[t].item[0]&&t<MAX;t++);
    if(t==MAX)return -1;
    return t;
}

void delete()
{
    register int slot;
    char s[80];
    printf("enter record #:");
    gets(s);
    slot=atoi(s);
    gets(s);
    slot=atoi(s);
    if(slot>=0&&slot<MAX)inv_info[slot].item[0]='\0';
}

void list()
{
    register int t;
    printf("used/total:%d/%d\n\n",usednum(),MAX);
    for(t=0;t<MAX;t++)
    {
        if(inv_info[t].item[0])
        {
            printf("item:%s\n",inv_info[t].item);
            printf("cost:%f\n",inv_info[t].cost);
            printf("onhand:%d\n\n",inv_info[t].onhand);
        }
        printf("\n");
    }
}

int usednum()
{
    int t,usednum1=0;
    for(t=0;t<MAX;t++)
    {
        if(inv_info[t].item[0]!='\0')usednum1++;   
    }
    return usednum1;
}


图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: return MAX item int printf 
2017-12-23 21:09
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10537
专家分:42927
注 册:2014-5-20
收藏
得分:5 
中止enter()过程返回到调用enter()之后。
2017-12-23 22:58
forever74
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:CC
等 级:版主
威 望:58
帖 子:1685
专家分:4252
注 册:2007-12-27
收藏
得分:5 
没有返回值正是void型函数的标准解决方案。

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2017-12-24 00:17
快速回复:第62行 return; 的返回值是什么?
数据加载中...
 
   



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

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