C++ 随机字符串生成函数
2018-07-20 来源:open-open
//C++ 随机字符串生成函数
#include<iostream>
#include<ctime>
using namespace std;
const int LEN_NAME=4;
char *rand_str(char *str,const int len)
{
int i;
for(i=0;i<len;++i)
str[i]='A'+rand()%26;
str[++i]='\0';
return str;
}
void main()
{
srand(time(NULL));
int i;
char name[LEN_NAME+1];
for(i=0;i<20;++i)
{
cout<<rand_str(name,LEN_NAME)<<endl;
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:python高强度密码生成器
最新资讯
热门推荐