Windows程序设计零散知识点

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/SuperYang_/article/details/79454882

文章中部分内容和思路来自《windows程序设计(第五版)》


1.宽字指针指向的子串需要加L,如:

wchar_t *p = L"hello world";
static wchar_t a[] = L"hello world";


2.传统的strlen, strcpy函数参数不能接受宽字符,正常来说处理宽字符有其对应的处理函数,如strlen对应于宽字符处理函数wcslen

3.TCHAR.H中定义了一些国际化的字符串处理函数,使用宏区分了ASCII和UNICODE,类似于:

#ifdef UNICODE
#define _tcslen wcslen
#else
#define _tcslen strlen
#endif


4.windows程序中不能使用printf,但可以使用sprintf,vsprintf,若需实现以下语句功能:

printf ("The sum of %i and %i is %i", 5, 3, 5+3) ;

可使用以下代码替代:

char szBuffer [100] ;
sprintf (szBuffer, "The sum of %i and %i is %i", 5, 3, 5+3) ;
puts (szBuffer) ;

5.windows程序设计多媒体使用需要链接windows多媒体库WINMM.LIB

6.UNREFERENCED_PARAMETER告诉编译器变量已经使用,不必再检测警告

猜你喜欢

转载自blog.csdn.net/SuperYang_/article/details/79454882
今日推荐