注册 登录
编程论坛 C语言论坛

请问C如何随机生成[10,25000]的字符串数组???拜托各位大佬🙏!!

宋致言 发布于 2019-12-17 18:22, 1340 次点击
请问C如何随机生成[10,25000]的字符串数组???拜托各位大佬🙏!!
1 回复
#2
宋致言2019-12-21 15:31
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<conio.h>
#define random(x)(rand()%x)
#define N 5


int main()
{
    srand(1);
    int flag,charLengt;
    int i,j,k=0;
    char ch[N+1]={NULL};
    char zh[N+1]={NULL};
    srand((unsigned)time(NULL));
    srand(time(NULL));
        for(i=0;i<25000;i++){
        for(j=0;j<N;j++){
            flag=rand()%2;
            if(flag)ch[k++]='A'+rand()%26;
            else ch[k++]='a'+rand()%26;
        }   
        ch[k]='\0';
        k=0;
    printf("%d %s %s %s %s %s %s %s %s %s\n",rand(),ch,ch,ch,ch,ch,ch,ch,ch,ch);
    }
   
}
1