| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 12442 人关注过本帖
标题:C 提示初始值设定项值太多 是什么意思?
取消只看楼主 加入收藏
PolinL
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-2-12
收藏
 问题点数:0 回复次数:1 
C 提示初始值设定项值太多 是什么意思?
代码如下
#include <stdio.h>
#define SLEN 40
#define LIM 5
int main(void)
{   
    const char *mytalents[LIM] = {
        "Adding numbers swiftly",
        "Multiplying accurately", "Stashing data",
        "Following instructions to the letter",
        "Understanding the C language"
    };
    char yourtalents[SLEN] = {
        "Walking in a staight line",
        "Sleeping", "Watching television",
        "Mailing letters", "Reading eamai"
    };

    system("pause");
    return 0;
}

14行sleeping部分被画红,提示初始值设定项值太多,是什么情况?
求大神解答,谢谢
搜索更多相关主题的帖子: 提示 初始值 设定 char the 
2018-03-04 22:52
PolinL
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-2-12
收藏
得分:0 
#include <stdio.h>
#define SLEN 40
#define LIM 5
int main(void)
{   
    const char *mytalents[LIM] = {
        "Adding numbers swiftly",
        "Multiplying accurately", "Stashing data",
        "Following instructions to the letter",
        "Understanding the C language"
    };
    char yourtalents[LIM][SLEN] = {
        "Walking in a staight line",
        "Sleeping", "Watching television",
        "Mailing letters", "Reading eamai"
    };
    int i;

    puts("Let's compare talents.");
    printf("%-36s  %-25s\n", "My Talents", "Your Talents");
    for (i = 0; i < LIM; i++)
        printf("%-36s  %-25s\n", mytalents[i], yourtalents[i]);
    printf("\nsizeof mytalents: %zd, sizeof yourtalents: %zd\n", sizeof(mytalents), sizeof(yourtalents));

    system("pause");
    return 0;
}
发现自己错误的地方了,修改红色部分后就正常运行了。
2018-03-04 23:06
快速回复:C 提示初始值设定项值太多 是什么意思?
数据加载中...
 
   



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

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