null and void

void pointers are called generic pointer can point to any type,

#include<stdio.h>
int main(){
	char a[]="dajiahao";
	char *p="Helo,world";
	printf("%s\n",p);
	printf("%s",a);
}
#include<stdio.h>
int main(){
	int num=1024;
	int *pi=#
	char *ps="Helloworld!";
	void *pt=pi;
//	printf("pi:%p  pt:%p\n",pi,pt);
	printf("%d\n",*(int*)pt);//注意强转
	pt=ps;
//	printf("pt:%p  ps:%p",pt,ps);
	printf("%s",(char*)pt);
	return 0;
}

 

NULL NULL pointer

When the pointer does not know why the initial address, please initialize it to NULL, when the pointer dereference, first check whether the pointer is NULL

 

#include <stdio.h>

int main()
{
	int *p1;
	int *p2 = NULL;

	printf("%d\n", *p1);
	printf("%d\n", *p2);

	return 0;
}

NUL is not NULL

 NULL pointers for the object and, a control, addressed to a not used, and '\ 0' end of the string

 

Guess you like

Origin www.cnblogs.com/helloworld2019/p/11105015.html