What's the difference between printf(“%s”), printf(“%ls”), wprintf(“%s”), and wprintf(“%ls”)?

前端 未结 3 991
闹比i
闹比i 2020-12-30 03:23

Consider this sample program:

#include 
#include 
#include 

int main()
{
    std::string narrowstr = \"narrow\";
          


        
3条回答
  •  北海茫月
    2020-12-30 04:21

    The answers to 1 and 2 are in the question are in the documentation. Any good set of documentation will do. They say cppreference is very good.

    As for 3, the language standard does not specify any particular encoding for strings, or any particular size of wchar_t. You need to consult the documentation for your implementation, rather than for the language proper (though writing implementation-dependent code is rarely advisable).

提交回复
热议问题