Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

How to store multi-byte into a char array in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main() 
{
    setlocale(LC_ALL, "C.UTF-8");

    printf("%lc\n", 0x00004e2d);
    printf("%lc\n", 0x00006588);
    printf("%lc\n", 0x00004a3d);

    wchar_t *arr = malloc(3 * sizeof(wchar_t));
    
    arr[0] = 0x00004e2d;
    arr[1] = 0x00006587;
    arr[2] = 0x00004a3d;
    
    printf("%ls\n", arr);
    
    free(arr);
}



/*
run:

中
斈
䨽
中文䨽

*/

 



answered Apr 22, 2024 by avibootz
edited Apr 22, 2024 by avibootz

Related questions

1 answer 91 views
91 views asked Apr 12, 2024 by avibootz
1 answer 153 views
2 answers 197 views
197 views asked Aug 10, 2015 by avibootz
1 answer 119 views
...