【问题标题】:please check this code for me , how to fix it?请帮我检查这段代码,如何解决?
【发布时间】:2022-12-07 01:51:02
【问题描述】:
#include<stdio.h>
#include<string.h>
void search(char str[],char ch);

int main()
{
    char str[50],ch;

    printf("Enter a string:");
    fgets(str,50,stdin);

    printf("\nEnter an alphabet to search: ");
    scanf("%c",&ch);
  
    return 0;
}

void search(char str [],char ch)
{
    int i,t=0;
    for ( i=0;str[i]!='\0';i++)
    {
        if (str[i]==ch)
        {
            t=1;
            break;
        }
    }

    if (t == 1)
    {
        printf("true");
    }
    else 
    {
        printf("false");
    }
    
}

输出

Enter a string:sayeeba

Enter an alphabet to search: v

我不知道如何解决它请帮助我。

问题是查找字符串中是否存在字符,如果存在则为真,否则为假。

【问题讨论】:

标签: c visual-studio-code


【解决方案1】:

你不见了

  search(str,ch);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 2014-12-26
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    相关资源
    最近更新 更多