摘要: 1 void foo(void) 2 3 { 4 5 unsigned int a = 6; 6 7 int b = -20; 8 9 (a+b > 6) puts("> 6") : puts("6”。原因是当表达式中存在有符号类型和无符号类型时所有的操作数都自动转换为无符号类型。因此-20变成了一个非常大的正整数,所以该表达式计算出的结果大于6。 阅读全文
posted @ 2013-08-15 17:37 CPYER 阅读(329) 评论(0) 推荐(0) 编辑
摘要: C语言库函数名: atoi功 能: 把字符串转换成整型数。名字来源:ASCII to integer 的缩写。原型: int atoi(const char *nptr);函数说明: 参数nptr字符串,如果第一个非空格字符存在,并且,如果不是数字也不是正负号则返回零,否则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。头文件: #include stdlib.h>程序例:1) 1 #include 2 #include 3 int main(void) 4 { 5 int n; 6 char *str = "12345.67"; 7 阅读全文
posted @ 2013-08-15 17:35 CPYER 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 一,C++语言的内建类型中没“BYTE”这么个类型。BYTE是WINDOWSPlatformSDK中windef.h里面定义的:typedefunsignedcharBYTE;二,char与 byte(JAVA)相同:c++中char型数组占一个字节。byte也占8个bit。不同:char 是字符型(-127 - 128;byte是字节型(0 - 255) .JAVA中byte类型的介绍:Java也提供了一个byte数据类型,并且是基本类型。java byte是做为最小的数字来处理的,因此它的值域被定义为-128~127,也就是signed byte。不幸的是,byte的用作计数的时间远少于用 阅读全文
posted @ 2013-08-15 17:33 CPYER 阅读(2085) 评论(0) 推荐(0) 编辑
摘要: 得到当前时间的方法一般都是得到从1900年0点0分到现在的秒数,然后转为年月日时分秒的形式得到当前的时间(时分秒)。主要方法如下:1)使用CRT函数C++代码1 char szCurrentDateTime[32]; 2 time_t nowtime; 3 struct tm* ptm; 4 time(&nowtime); 5 ptm = localtime(&nowtime); 6 sprintf(szCurrentDateTime, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", 7 ptm->tm_year + 1... 阅读全文
posted @ 2013-08-15 17:29 CPYER 阅读(1694) 评论(0) 推荐(0) 编辑
摘要: 以下对strcpy函数错误的是? 1 char atr1[]="string"; 2 3 char str2[10]; 4 5 char *str3; 6 7 char *str4="sting"; 8 9 10 A.strcpy(str1,"hello");11 B.strcpy(str2,"hello");12 C.strcpy(str3,"hello");13 D.strcpy(str4,"hello");C.strcpy(str3,"hello") 阅读全文
posted @ 2013-08-15 17:24 CPYER 阅读(467) 评论(0) 推荐(0) 编辑