指针恐怕是C语言中最不容易掌握的一个概念了,但指针又是如此的重要,可以说不会指针,C语言就等于没学。
指针到底是一个什么东西呢?
#include <stdio.h>
int main()
{
struct mySt
{
int age;
float money;
double weight;
float heigh;
};
char *pCh = NULL;
char *pStr = "Hello Pointer";
short *pShort = NULL;
int *pInt = NULL;
float *pFloat = NULL;
double *pDouble = NULL;
struct mySt* pStruct = NULL;
printf("sizeof(pCh) = %d\n", sizeof(pCh));
printf("sizeof(pStr) = %d\n", sizeof(pCh));
printf("sizeof(pShort) = %d\n", sizeof(pShort));
printf("sizeof(pInt) = %d\n", sizeof(pInt));
printf("sizeof(pFloat) = %d\n", sizeof(pFloat));
printf("sizeof(pDouble) = %d\n", sizeof(pDouble));
printf("sizeof(pStruct) = %d\n", sizeof(pStruct));
getcha