作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 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/
我正在用 C++ 编写程序,应该将文本中的字母更改为大写字母(程序可以运行,但 setlocale 不运行)。但它给了我错误。 [错误] 未在此范围内声明“LC_TYPE”。它“应该”起作用,因为它来
对于下面的 MySQL create database 语句,postgresql 中的等效语句是什么?: CREATE DATABASE IF NOT EXISTS `scratch` DEFA
我是一名优秀的程序员,十分优秀!