#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
//对输入的随机码进行判断
int Code_IsRight(char code[4])
{
char* p=code;
//....... 写不好了
return 0;
}
//随机码产生函数
void Randomcode()
{
int Rcode=1000+rand()%9000;//产生1000-9000的随机数
printf("\n随机码:%d\n",Rcode);
}
int main()
{
char code[4]={0};//code数组存放随机码
srand((unsigned int)time(NULL));
Randomcode();
printf("\n请输入随机码:");
scanf("%s", code);
Code_IsRight(code);//对用户输入的随机码进行判断,是否正确
return 0;
}
求问:如何在Code_IsRight( )函数里判断输入的随机码是否正确?
有没有大神可以解答一下,谢谢!