|
1鱼币
本帖最后由 风之残月 于 2014-11-10 10:26 编辑
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
char *str;
p=(int*)malloc(sizeof(int));
str=(char*)malloc(sizeof(char[20]));
printf("请输一个整数:\n");
scanf("%d",p);
printf("请输一个字符串:\n");
scanf("%s",str);
printf("你刚刚输入的整数为:%d\n",*p);
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
char *str;
p=(int*)malloc(sizeof(int));
str=(char*)malloc(sizeof(char[20]));
printf("请输一个整数:\n");
scanf("%d",p);
printf("请输一个字符串:\n");
scanf("%s",str);
printf("你刚刚输入的整数为:%d\n",*p);
printf("你刚刚输入的字符串为:%s\n",str);
return 0;
}
这段代码是正确的,但是我很疑惑,为什么这一句printf("你刚刚输入的字符串为:%s\n",str);这个str为什么没有取值操作符*.我非常的不能理解.
|
|