首页 > 解决方案 > 'strrev' 未在此范围内声明

问题描述

编译后我得到“此代码中未声明 strrev”,似乎我不能在 strcpy 中使用 strrev?如果是这样,将 strrev(b) 的值分配给 char 数组会解决它吗?这是代码:

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

ifstream fin("palindrom.in");
ofstream fout("palindrom.out");

int main(){
    int i, n = 0, x, v[100], q=0;
    char a[256], b[256], rev[256], be[256];
    
    int ind=0;
    fin>>x;

    fin.get();
    for(i = 0; i < x; i++){
        fin.get(a, 256);
        fin.get();

        for(int j = 0; j < strlen(a); j++){
            if(!strchr(" ", a[j])){
                b[n++] = a[j];
            }
        }
        b[n++] = 0;
        strcpy(be, b);
        strcpy(rev, strrev(b));

        if(strcmp(be, rev) == 0){
            v[ind++] = 1;
        }
        else{
            v[ind++] = 0;
        }

        memset(b, 0, 256);
        n = 0;
    }

    for(i = 0; i < x; i++){
        fout<<v[i]<<endl;
    }
}

这是发生错误的地方

标签: c++c-strings

解决方案


推荐阅读