gpt4 book ai didi

c++ - 错误 'LC_TYPE' 未在此范围内声明

转载 作者:行者123 更新时间:2023-11-28 06:19:02 25 4
gpt4 key购买 nike

我正在用 C++ 编写程序,应该将文本中的字母更改为大写字母(程序可以运行,但 setlocale 不运行)。但它给了我错误。 [错误] 未在此范围内声明“LC_TYPE”。它“应该”起作用,因为它来 self 的官方教员文献。

#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Write something: " << endl;
string tekst; //tekst=text
getline(cin, tekst);

setlocale(LC_TYPE, "croatian"); // here is problem...

for (char znak : tekst){ //znak=char, symbol...
char velikoSlovo = toupper(znak); // velikoSlovo=uppercaseLetter
cout << velikoSlovo;
}
cout << endl;
return 0;
}

谁知道怎么解决?我正在使用 Orwell Dev C++ 5.9.2。语言标准 (-std) 是 ISO C++ 11。 Here is picture.

最佳答案

你不需要包括#include <clocale>吗?据说here

编辑:其实#include <locale.h>应该优先于 <clocale>以减少便携性问题。感谢@Cheers 在评论中提到它。

关于c++ - 错误 'LC_TYPE' 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29637362/

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