Search code examples
c++setlocale

Error 'LC_TYPE' was not declared in this scope


I'm writing program in c++ that is supposed to change letters in text to uppercase letters(Program works, but setlocale is not working). But it is giving me Error. [Error] 'LC_TYPE' was not declared in this scope. It "should" work because it is from my official faculty literature.

#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;
}

Anyone knows how to fix this?? I'm using Orwell Dev C++ 5.9.2. Language standard (-std) is ISO C++ 11. Here is picture.


Solution

  • Don't you need to include #include <clocale> as it is said here

    Edit: Actually #include <locale.h> should be preferred to <clocale> to reduce portability issues. Thanks to @Cheers for mentioning it in the comments.