问题遇到的现象和发生背景
#include<stdio.h>
#include <time.h>
#include <stdlib.h>
int main(void)
{
int years = 2003, mouth = 05;
//display member 1
printf("member 1: ");
//display the years,mouth and code
//the years can't bigger than 2022
if (years < 2023)
{
printf("%d", years);
}
else
{
printf("this is wrong");
}
//the mouth can't bigger than 13
if (mouth<13)
{
printf("%d", mouth);
}
else
{
printf("this is wrong");
}
// make a random 4 digit number
srand(time(NULL));
int r = rand(4);
printf("%d",r);
printf("\n");
//display member 2
char firstname = "Lux", middlename = "AA", lastname = "RR";
printf("member 2:\n");
printf("–first member is %s \n", &firstname);
printf("–middle member is %s \n", &middlename);
printf("–last member is %s \n", &lastname);
return 0;
}
我设置月是05但不能识别到0
还有就是char不能正常运行
我想要达到的结果
年月随机4个数字
– first member is ”Lux”
– second member is ”AA”
– third member is ”RR“