forked from sehejjain/DIS-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserId.cpp
More file actions
40 lines (32 loc) · 664 Bytes
/
userId.cpp
File metadata and controls
40 lines (32 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;
#define POOLSIZE 62;
void generateUniqueID(char *ID, int size)
{
srand(time(NULL));
char pool[62];
int index = 0;
for (int i = 0; i < 26; i++)
{
pool[index++] = i + 'A';
}
for (int i = 0; i < 9; i++)
{
pool[index++] = i + '0';
}
for (int i = 0; i < 26; i++)
{
pool[index++] = i + 'a';
}
for (int i = 0; i < size; i++)
{
int poolIndex = rand() % (61);
ID[i] = pool[poolIndex];
}
ID[size - 1] = '\0';
// temp
cout<<"Generated ID: "<<ID<<endl;
}