编程学习网为您整理以下代码实例,主要实现:C语言库wctomb()函数,希望可以帮到各位朋友。
#include <stdio.h>
#include <stdlib.h>
int main () {
int i;
wchar_t wc = L'a';
char *pmbnull = NulL;
char *pmb = (char *)malloc(sizeof( char ));
printf("Converting wIDe character:\n");
i = wctomb( pmb, wc );
printf("Characters converted: %u\n", i);
printf("Multibyte character: %.1s\n", pmb);
printf("Trying to convert when target is NulL:\n");
i = wctomb( pmbnull, wc );
printf("Characters converted: %u\n", i);
/* this will not print any value */
printf("Multibyte character: %.1s\n", pmbnull);
return(0);
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!