本人用C语言编的姓名和学号随机生成代码有乱码问题,求大神指导
一下是本人编写的C语言姓名和学号随机生成代码,但是在随机生成姓名的时候,姓名出现乱码很严重,求大神改进代码#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<math.h>
struct stu{
long ID;
char name[4];
char num[13];
}wanghongsheng;
char *family="王李张刘陈杨黄赵吴周徐孙马朱胡郭何高林罗郑梁谢宋唐许韩冯邓曹彭曾肖田董袁潘于蒋蔡余杜叶程苏魏吕丁任沈姚卢姜崔钟谭陆汪范金石廖贾夏韦傅方白邹孟熊秦邱江尹薛闫段雷侯龙史陶黎贺顾毛郝龚邵万钱严覃武戴莫孔向汤";
char *boyname="伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘";
char *girlname="秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽";
char *mix="澜华秋娣桂凤旭先丽娜朋政香致仁晨云雅柔泰宜宁善荷娅腾霭妍彬欢媛琼婉青树淑浩露彩风红璧璐杰波萍全纨纯江义君健飞羽震春振凡薇龙才航豪德翔胜思黛菁发爽园克昌茂艳军嘉影进珠辉朗炎环永姬婵丹瑾维世荔勇枫刚蓓毅惠亨保士雄琬霄素友群哲强勤康芸峰筠元菊若厚鸣英志楠达东亚锦艺兰仪慧山可广霞国娟信武清兴琰中庆聪成翰冠贵言婕馨心卿琛菲裕芝诚伊学榕固荣晶博娴希梁雁妹松瑞苑燕邦策斌翠珊月飘河美姣育宁子力时民昭怡明辰蕊奇功莎叶眉会栋冰新磊承轮瑶馥之伯彪建茜寒林坚敬安岩欣颖莺祥海茗良悦乐启巧晓以亮盛有婷爱梅顺壮宏生竹谦倩莲玉钧思玲利真平滢韵佳珍琳琴洁福娥静莉星超和凝家伟光梦文芳瑗融舒富岚天琦雪泽弘咏枝秀芬贞绍鹏蓉涛伦行俊毓";
int main()
{
FILE *fp;
int i; //生成数量
int j; //用于姓名赋值的循环计数
char name[4];
srand((unsigned)time(NULL));
fp=fopen("wang.txt","w");
if(fp==NULL)
{
printf("文件打开错误");
}
// for(i=0;i<2000;i++)
// {
// strcpy(&wanghongsheng.ID,(char)rand());
// strcpy(&wanghongsheng.name,(char)rand());
// strcpy(&wanghongsheng.num,(char)rand());
//strcpy(wanghongsheng.name,(char)rand()*rand()*rand()*rand());
//strcpy(wanghongsheng.num,(char)rand()*rand()*rand()*rand());
for(i=0;i<10000;i++)
{
printf("第%d条身份证信息生成中\n",i+1);
name[0]=family[abs(rand()*rand()%100)];
name[1]=boyname[abs(rand()%100)];
// fputc(name);
// fputs(name,fp);
if(rand()%2==0)
{
name[2]=boyname[abs(rand()%96)];
name[3]='\0';
}
else
name[2]='\0';
//for()
// strcpy(wanghongsheng.name,name[3]); //还是采用传统方法吧
for(j=0;j<4;j++)
{
wanghongsheng.name[j]=name[j];
}
// fputs(name,fp);
wanghongsheng.ID=abs(rand()*rand()*rand()*rand()%1000000000);
//学号赋值
// scanf("%s%s%s",&wanghongsheng.ID,&wanghongsheng.name,&wanghongsheng.num);
// fprintf(fp,"%s\t%s\t%s\n",wanghongsheng.ID,wanghongsheng.name,wanghongsheng.num);
fprintf(fp,"%s\t%ld\n",wanghongsheng.name,wanghongsheng.ID);
// printf("%s\n",wanghongsheng.name);
}
fclose(fp);
return 0;
}
令求问,如何利用模糊信息快速查找完整信息的代码编写(大数据)