当前位置:   article > 正文

生成8位随机字母数字组合_随机生成八位数字字母组合

随机生成八位数字字母组合
  1. #include <unistd.h>
  2. #include <time.h>
  3. #include <sys/time.h>
  4. int rand_8(char *str)
  5. {
  6. char pool[] = {'0','1','2','3','4','5','6','7','8','9', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  7. int i = 0;
  8. struct timeval tpstart;
  9. gettimeofday(&tpstart,NULL);
  10. srand(tpstart.tv_usec);
  11. while(i != 8){
  12. str[i++] = pool[rand()%sizeof(pool)];
  13. }
  14. return 1;
  15. }

参考:

linux中c语言精确计时函数的使用_兵临城下-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/169847
推荐阅读
相关标签
  

闽ICP备14008679号