字符串是否存在字符c

#include <iostream>

using namespace std;

char* strchar(char *str, char c);
int main()
{
    char s[100], c;
    cin.getline(s, 100, '\n');
    cin >> c;
    char *p = strchar(s, c);
    cout << p << endl;
}
char *strchar(char *str, char c)
{
    while (*str != '\0')
    {
        if (*str == c)
            cout << "YES";
        else 
            str++;
    }
    cout << "NO";
}

编写一个函数,查找给定字符串str中是否存在某字符c,若存在则返回一个指向str中ch首次出现的位置,若没有在str中找c到返回nullptr。在主函数中输入字符串和待查找字符,若找到输出“YES”,否则输出“NO”。函数原型:char * strchar( char *str, char c );

函数没问题,这么输出yes或no?(இдஇ; )

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    getline(cin, str);
    char c;
    cin >> c;
    if (str.find(c) == string::npos)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

不会