标准C的头文件assert.h学习总结
1:类似junit的断言,只是在assert中的断言,如果不满足的话就程序退出。
比如
#include <assert.h>
int main(void)
{
assert(6 < 5);
system("pause");
return 0;
}
在执行到assert(6 < 5);
的时候因为不满足断言,于是程序退出。
如果不想让assert(6 < 5)起作用,就在最上面添加宏定义#define NDEBUG
要添加在#include <assert.h>上面才起作用
全部的如下:
#define NDEBUG
#include <assert.h>
int main(void)
{
assert(6 < 5);
system("pause");
return 0;
}
相关文档:
#include <stdio.h>
#define SIZE 50
int main()
{
FILE *fps=NULL;
fps=fopen("tests.txt","r");
FILE *fpd=NULL;
fpd=fopen("testd.txt","wt+");
fseek(fpd,0,SEEK_END);
char buffer[SIZE];
while (fps || fpd)
{
int t=fread(buffer,sizeof(char),SIZE,fps);
if (t==0)
{
bre ......
char * c = "hello"; c是个分配在堆栈中的一个变量。里面装的是字符串hello的首地址,而hello是常量区。PE文件在编译的时候就确定了的。
char []c = "hello";
"hello"是放在堆栈中保存的,跟上面的那个例子不同,由于hello是堆栈中的所以是可以修改的。而常量区里的是不可以修改的。因为PE的内存页属性是只读的。当然可以 ......
扫描结果
----------------------
C:\Documents and Settings\ibmuser\Local Settings\Application Data\S-1-5-31-1286970278978-5713669491-166975984-320\Rotinom\RECYCLER.exe 蠕虫病毒(Worm.Generic.221028) 已删除
C:\Documents and Settings\ibmuser\Local Settings\Application Data\S-1-5-31-12869702 ......
什么是空指针常量(null pointer constant)?
[6.3.2.3-3] An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
这里告诉我们:0、0L、'\0'、3 - 3、0 * 17 (它们都是“integer constant expression”)以及 (void*)0 等都是空 ......