void*类型的形参

void*类型的形参


#include
void print(void *p_vd,int type){
	if(type == 1){
		prntf("%d\n",*(int*)p_vd);
	}
	else if(type == 2){
		prntf("%c\n",*(char*)p_vd);
	}
	else{
		prntf("%g\n",*(float*)p_vd);
	}
}
int main(){
	int num = 10;
	char ch = 'a';
	float fnum = 5.7f;
	printf(&num,1);
	printf(&ch,2);
	printf(&fnum,3);
	return 0;
}


你可能感兴趣的:(void*类型的形参)