Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding Unique_Code_Generator #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .cpp/Unique_Code_Generator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include <string.h>
#include <ctime>
#include <bits/stdc++.h>
using namespace std;

string randomString(int maxLength = 5, string charIndex = "abcdefghijklmnaoqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
{
int length = maxLength;
int indexesOfRandomChars[15];
for (int i = 0; i < length; ++i)
indexesOfRandomChars[i] = rand() % charIndex.length();
string randomString = "";
for (int i = 0; i < length; ++i){
randomString += charIndex[indexesOfRandomChars[i]];
}
return randomString;
}

int main(){

string kode_unik;
srand(time(NULL));
kode_unik=randomString();
cout<<"\n Kode Unik Anda = "<<kode_unik<<;

}