1. 指向字符串的指针强制转换成指向整型的指针:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv)
{
char buffer[500];
memset(buffer, 0, 500);
*(int *)buffer = 123;
printf("buffer is %d\n", *buffer);
return 0;
}
2.指向整型的指针强制转换成指向字符串的指针
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
unsigned char *buf;
int a = 75;
buf = (unsigned char *)&a;
printf("buf is %s\n", buf);
return 0;
}