level 5
仗剑烤鱼丸丶♀
楼主
想了好久了,想不出什么毛病,在线等,求大神指导。
为什么输出的和输入的不一样,第二个问题是第二次输入时,我给第一个名字输入字符串时加了个空格结果点了一下回车就出结果了,而且输出的字符串依然有问题
源代码:
#include<stdio.h>
struct add
{
char *q;
char *w;
}as;
char a;
char b;
int main(void)
{
as.q=&a;
as.w=&b;
int d=0;
while(1){
puts("输入名字");
scanf("%s",as.q);
puts("输入地址");
scanf("%s",as.w);
printf("名字\n%s\n地址\n%s\n",as.q,as.w);
puts("重输按2,结束按1");
scanf("%d",&d);
if(d==1)
{
printf("\n\nover.\n");
break;
}}
return 0;
}

2018年05月08日 16点05分
1
为什么输出的和输入的不一样,第二个问题是第二次输入时,我给第一个名字输入字符串时加了个空格结果点了一下回车就出结果了,而且输出的字符串依然有问题
源代码:
#include<stdio.h>
struct add
{
char *q;
char *w;
}as;
char a;
char b;
int main(void)
{
as.q=&a;
as.w=&b;
int d=0;
while(1){
puts("输入名字");
scanf("%s",as.q);
puts("输入地址");
scanf("%s",as.w);
printf("名字\n%s\n地址\n%s\n",as.q,as.w);
puts("重输按2,结束按1");
scanf("%d",&d);
if(d==1)
{
printf("\n\nover.\n");
break;
}}
return 0;
}
