小编Loo*_*out的帖子

C++中的strchr在哪里?

我知道那strchr是在<string>.但是uva10082给了CE:

code.cpp: In function ‘int main()’:
code.cpp:6:13: warning: unknown escape sequence: '\A'
char x[] = "`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";          ^
code.cpp:11:24: error: ‘strchr’ was not declared in this scope
p = strchr(x, char(c));
Run Code Online (Sandbox Code Playgroud)

这是我的代码:(用c ++ 11编译)

#include<iostream>
#include<string>
using namespace std;
int main()
{
    char x[] = "`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";
    int c;
    char* p = NULL;
    while ((c = getchar()) != EOF)
    {
        p =strchr(x,char(c));
        if (p)
            cout << *(p-1);
        else
            cout << char(c);
    }
}
Run Code Online (Sandbox Code Playgroud)

c c++ c++11

1
推荐指数
1
解决办法
2298
查看次数

标签 统计

c ×1

c++ ×1

c++11 ×1