-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrand.c
More file actions
41 lines (37 loc) · 787 Bytes
/
crand.c
File metadata and controls
41 lines (37 loc) · 787 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
41
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void print();
int main(int argc,char* argv[])
{
if (( argv[1] == "-h" ) || (argv[1] == "--help") || (argv[1] == NULL) )
{
print();
}
else
{
int ammount;
if ( argv[1] == NULL)
{
ammount = 10 ;
}
else
{
ammount = atoi(argv[1]);
}
char string[ammount];
srand(time(NULL));
int limit = ammount + 1;
for( int i = 0; i < limit; ++i){
string[i] = '0' + rand()%72; // starting on '0', ending on '}'
}
printf("%s\n",string);
}
//printf("%s", argv[1]);
return 0;
}
void print()
{
printf (" help: \n This tool just print random strings usefull for scripting \n Just give a argument of how many characters \n here an example: \n crand 32 will print 32 random strings\n");
}