标题:这有问题吗?
只看楼主
不就是头发吗
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-8-2
结帖率:0
已结贴  问题点数:20 回复次数:1 
这有问题吗?
#include <stdio.h>
#include <string.h>

#define MAXS 80

int getindex( char *s );

int main()
{
    int n;
    char s[MAXS];

    scanf("%s", s);
    n = getindex(s);
    if ( n==-1 ) printf("wrong input!\n");
    else printf("%d\n", n);

    return 0;
}
int getindex(char *s)
{
      const char *p[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    int i,IF=0;
    for(i=0;i<7;i++)
    {
        if(strcmp(*s,p[i])==0)
        {
            return i;
            break;
        }
        printf("%s\n",p[i]);
    }
    if(IF==0)
        return -1;
}

//26    26    C:\Users\ASUS\Documents\未命名11.cpp    [Error] invalid conversion from 'char' to 'const char*' [-fpermissive]
搜索更多相关主题的帖子: char int return include printf 
2020-08-02 07:24
纯蓝之刃
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:76
帖 子:554
专家分:3690
注 册:2019-7-29
得分:20 
(strcmp(s,p[i])

一沙一世界,一花一天堂。无限掌中置,刹那成永恒。
2020-08-02 08:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502720-1-1.html




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

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