C随机生成18位银行卡号

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "timeb.h"
static char id[21];
static char buf[11];
main()
{
 char ch;
 struct timeb t;
 clrscr();
 puts("******************************");
 puts("make number of band's id randly.");
 puts("press 'q' to exit.");
 puts("press any key to make.");
 puts("******************************");
 ftime(&t);
 srand(t.millitm); /*毫秒作为种子值*/
 while((ch=getchar())!='q')
 {
  sprintf(buf,"%.8f",rand()/(0x7fff+1.0));
  strcpy(id,"4300 4600 ");  /* 前8位固定*/
  strncat(id,buf+2,4);
  strcat(id," ");
  strncat(id,buf+6,4);
  id[20]='/0';
  printf(" >>id number:%s/n",id);
 }
 getch();
}

你可能感兴趣的:(c,include)