c语言输入某年某月某日
时间: 2023-07-09 16:28:10 浏览: 47
以下是使用 C 语言输入某年某月某日的示例代码:
```c
#include <stdio.h>
int main() {
int year, month, day;
printf("请输入年份:");
scanf("%d", &year);
printf("请输入月份:");
scanf("%d", &month);
printf("请输入日期:");
scanf("%d", &day);
printf("您输入的日期为:%d年%d月%d日\n", year, month, day);
return 0;
}
```
在上述代码中,我们使用 `scanf` 函数分别读取用户输入的年份、月份和日期,并使用 `printf` 函数将其输出。需要注意的是,由于用户可能会输入非法的日期,因此在实际开发中需要加入相应的输入校验。
相关推荐
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rp](https://img-home.csdnimg.cn/images/20210720083646.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)