C language string width

/ * Width print string * / 
#include <stdio.h> 
#include <stdlib.h> 
#include < String .h> 
#include <wchar.h> 
#include <of locale.h for>    / * Convert wide character * /

void show(void)
{
    const wchar_t * pw = L " Today the weather is not bad! " ;

    /*
    Design Notes:
        If you print Chinese characters, setlocale () is a must
    */
    setlocale(LC_ALL, "zh_CN.UTF-8");

    /*
    Knowledge added:
        printf and wprintf not mix, that a program uses printf, do not use wprintf, and vice versa, since printf output char and wchar_t characters are so consistent use printf is the best choice.
    */

    // the printf wide string print 
    the printf ( " --printf - [LS%] ------ \ n- " , PW);
    printf("--printf--[%S]------\n", pw);

    /// / print the wprintf wide string 
    // the wprintf (L "- the wprintf - [LS%] ------ \ n-", PW);
     // the wprintf (L "- the wprintf - [% S] ------ \ n-", PW); 
}

int main ()
{
    show();
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/zhanggaofeng/p/11666054.html