C++_生成随机字符串
2013-03-21 14:39
246 查看
#include<iostream> #include<ctime> using namespace std; const int LEN_NAME=10; char *rand_str(char *str,const int len) { int i; for(i=0;i<len;++i) str[i]='A'+rand()%26; str[i+1]='\0'; return str; } void main() { srand((unsigned)time(NULL)); char name[LEN_NAME+1]; cout<<rand_str(name,LEN_NAME)<<endl; }
若出现Stack around the variable ‘name’ was corrupted,就把project->配置属性->c/c++->代码生成->基本运行时检查改为默认值。
相关文章推荐
- c++中生成n个m位的随机不重复字符串的一种方法(字母+数字)
- C++ 随机生成数字和字母组合的字符串
- shell 生成指定范围随机数与随机字符串 .
- Java——随机生成一个字符串
- 生成n位随机字符串
- 通过bash命令生成足够随机的秘钥字符串
- 编写一个生成随机字符串的方法,参数接收长度,字符串中可能含有大写字母、 小写字母和数字。
- Java 生成随机字符串的方法之一(字母数组混合)
- 利用openssl_random_pseudo_bytes和base64_encode函数来生成随机字符串
- 生成n位随机字符串(转)
- 如何随机生成01随机字符串
- Asp生成十三位随机字符串
- java 生成 序列号 随机字符串等
- PHP生成随机字符串
- 随机生成字符串
- C++ COM编程生成随机GUID值
- php生成随机字符串可指定纯数字、纯字母或者混合的
- c++获取时间并生成字符串
- VC++ GUID随机字符串生成
- 生成随机字符串