C Tutorial/stdlib.h/mbtowc

Материал из C\C++ эксперт
Перейти к: навигация, поиск

mbtowc

Item Value Header file stdlib.h Declaration int mbtowc(wchar_t *out, const char *in, size_t size); Function converts the multibyte character *in into its wide-character equivalent *out. Only size number of characters will be examined. Return returns the number of bytes that are put into *out or -1 or error. If in is null, then mbtowc() returns nonzero if multibyte characters have state-dependent encodings. If they do not, zero is returned.


<source lang="cpp">#include <stdlib.h>

  1. include <stdio.h>

int main(void){

 char *mb = "asdfadsf";
 char str[1000];
 mbtowc(str, mb, 2);

 printf("%s",str);

}</source>