gpt4 book ai didi

c++ - 为什么不能在 if 条件下比较两个字符串?

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:07:17 27 4
gpt4 key购买 nike

<分区>

为什么不能在 if 条件下比较两个字符串?

#include <iostream>
#include <string.h>

using namespace std;

int main() {
string sexo[20], feminino;
feminino = "f";

for (int i = 0; i < 3; i++) {
do {
cout << endl << "enter your " << i + 1 << "sexo: ";
cin >> sexo[i];

if (strcmp(sexo[i], feminino)==0){ // problem in here
cout << "that's ok" << endl;
}

} while (nome[i] == "0");
}
return 0;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com