大神们,这道题已经好几天了,还做不出来,求大神

使用scanf()函数从键盘输入自己的姓名和年龄,然后显示 本关任务:提示用户从键盘输入自己的姓名和年龄,然后显示,“Hello 姓名,your age is 年龄”,使用scanf()函数和printf()函数。

你做几天做成什么样了?代码呢?你贴出来你的代码,我能看看你做几天什么成果吗。

#include int main(void) char initial= ' '; char name[80]=l'']; char age[4]=('0' ]; printf("Enter your first initial: "); scanf_ .s(" %c", &initial, sizeof(initial)); printf("Enter your first name: "); scanf_ .s("%s", name, sizeof(name)); fflush(stdin); //用来清空标准输入、输出缓冲区,fflush(stdin)、 fflush(stdout) if (initial != name[0]) printf(" %s ,you got your initial wrong.\n" , name); else printf("Hi, %s. Your initial is correct. Well done!n" , name); printf("Enter your full name and your age separated by a comma:1n");scanf_ .s(" %[' ,] , %[0123456789]", name, sizeof(name), age, sizeof(age));printf("\nY our name is %s and you are %s years old.\n", name, age); return 0; 30

这个也不行

#include <stdio.h>
void main()
{
	char name[3];
	int age;
	printf("请从键盘输入自己的姓名和年龄:\n");
	scanf("%s",name);
	scanf("%d",&age);
	printf("Hello %s,your age is %d\n",name,age);
}

 

 #include <stdio.h> 
 int main(void) 
 { 
     int age; char name[10]; 
     printf("Please input your name:");
     scanf("%s",&name); 
     printf("请Please input your age:");
     scanf("%d",&age); 
     printf("Hello %s,your age is %d\n",name,age);
     return 0; 
 }

 

运行结果如下