How to assign to string the japanese word ネコ in C++

1 Answer

0 votes
#include <iostream>
#include <string>

int main() {
    std::string str1 = "ネコ"; // cat
    std::string str2 = u8"ネコ";

    std::cout << str1 << "\n";
    std::cout << str2 << "\n";
}

   
/*
run:
   
ネコ
ネコ
   
*/

 



answered Apr 19, 2025 by avibootz
...