我的问题是关于取消引用 char 指针
这是我的代码 -
#define MAX 10
char s[80]="Hello";
int main(){
char *stackValue;
stackValue=&s;//here I assined the address of s to stackValue
if(!stackValue){
printf("No place for Value");
exit(1);
}
else{
printf("\n%s",*stackValue);//This doesn't work with * before it
printf("\n%s",stackValue);//This works properly
}
return 0;
}
在上面的代码中,我将 S[] 的地址分配给了 stackValue,当我打印 *stackValue 时它不起作用,
但如果我只打印 'stackValue' 那行得通。
当我用整数做同样的事情时
int main(){
int i=10, *a;
a=&i;
printf("%d",*a);//this gives the value
printf("%d",a)//this gives the address
return 0;
}
是打印字符指针和整数指针是不同的。当我在 int 值中使用 * 时,它会给出值,但当我将它用作 char 指针时会给出错误。
帮帮我?