03 2014 档案

getopt()——命令行参数分析
摘要:getopt(分析命令行参数)相关函数表头文件 #include extern char *optarg; //选项的参数指针 extern int optind, //下一次调用getopt的时,从optind存储的位置处重新开始检查选项。 extern int opterr, //当opterr=0时,getopt不向stderr输出错误信息。 extern int optopt; //当命令行选项字符不包括在optstring中或者选项缺少必要的参数时,该选项存储在optopt 中,getopt返回'?’、定义函数 int getopt(int argc,char * cons. 阅读全文

posted @ 2014-03-07 10:25 ★行云流水★ 阅读(1032) 评论(0) 推荐(0)

宽字符与多字符相互转换
摘要:宽字符:每个字符统一占4个字节, sizeof(wchar_t) = 4,编码格式为Unicode。多字符:对于字符和数字,每个字符占1个字节,每个汉字占3个字节。sizeof(char) = 1, sizeof(汉字) = 3,编码格式为GBK多字符串与宽字符串之间的转换:代码示例如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 int main() 8 { 9 wchar_t *wstr = L"abcd一二三四", *wst;10 char *mstr="五六七八xyz", 阅读全文

posted @ 2014-03-02 21:03 ★行云流水★