大量建帳號的方法
uid=6410 (第1步驟所記下的號碼 +1 )
gid=801 (第2步驟所記下的號碼 )
home=/home/class1 (第3步驟所記下的目錄)
h91910001 T123323248 (帳號 和 密碼 中間用1個空格隔開)
h91910002 G123233557
h91910003 G123233557
h91910004 G123233557(如需自動產生帳號及隨機密碼, 請看步驟9)
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
// char set : 33 ~126 , A~Z : 65~90 , a~z : 97~122
#define first_char 65
#define last_char 90
#define password_length 8
main(void)
{
char a[10],c;
int i,j,l,n;
srand((unsigned) time(NULL));
printf("How many account do you want ? ");
scanf("%d",&n);
printf("Input the prefix of account :");
scanf("%s",a);
for(i=1;i<=n;i++)
{
if(n>9 && i>9) printf("%s%d ",a,i); else printf("%s0%d ",a,i);
for(j=1;j<=password_length;j++)
{
l = last_char - first_char + 1;
c = rand() % l + first_char;
printf("%c",c);
}
printf("\n");
}
}