/ =====================================================================================
//
// Filename: char.c
//
// Description: char size test
//
// Version: 1.0
// Created: 2013年03月17日 17时01分13秒
// Revision: none
// Compiler: g++
//
// Author: Li Weijian (), lwj1396@163.com
// Company:
//
// =====================================================================================
#include<stdio.h>
#include<wchar.h>
#include<locale.h>
//c语言闭包
typedef void(*func_t)();
func_t test()
{
void func1()
{
printf("%s\n", __func__);
};
return func1;
}
int main(){
//字符常量默认是一个 int 整数,但编译器可以自行决定将其解释为 char 或 int
char c = 'a';
printf("%c, size(char)=%d, size('a')=%d;\n", c, sizeof(c), sizeof('a'));
printf("%d\n", sizeof(char*));
//中文字符处理
setlocale(LC_CTYPE, "en_US.UTF-8");
wchar_t ws[] = L"中国人";
printf("%ls\n",ws);
printf("%ls len %d, size %d\n",ws, wcslen(ws), sizeof(ws));
unsigned char* b = (unsigned char*)ws;
int len = sizeof(ws);
for (int i = 0; i < len; i++)
{
printf("%02X ", b[i]);
}
printf("\n");
//c语言闭包
func_t t = test();
t();
//参数从右往左入栈
int fa()
{
printf("a\n");
return 'a';
}
int fb()
{
printf("b\n");
return 'b';
}
printf("%d , %d\n",fa(),fb());
}
c99 学习笔记
最新推荐文章于 2024-12-12 13:31:14 发布