问一个关于 指针赋值 的问题
药不能停啊 2008-02-22 06:02:15 本人代码
// testPoint.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <string.h>
void FuZhi(char *argP)
{
argP = "abc";
}
int main(int argc, char* argv[])
{
char *p = NULL;
char str[10];
// memset(str, 10, sizeof(char));
printf("the address of str is %x\n", &str);
p = str;
// p = (char*)malloc(10*sizeof(char));
printf("&p = %x\n", &p);
printf("*p = %x\n", p);
FuZhi(p);
printf("str = %s\n", str);
printf("p = %s\n", p);
return 0;
}
调试的结果是下面:
the address of str is 12ff70
&p = 12ff7c
*p = 12ff70
str = フフフフフフフフフフフフp
p = フフフフフフフフフフフフp
Press any key to continue
想问:
问什么str 和指针p不等于 abc