File: random_string.c

package info (click to toggle)
slony1-2 2.2.11-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 9,040 kB
  • sloc: ansic: 21,487; sh: 12,997; sql: 11,337; xml: 9,202; javascript: 6,409; perl: 2,829; yacc: 2,698; lex: 1,356; makefile: 738; awk: 24; lisp: 8
file content (25 lines) | stat: -rw-r--r-- 374 bytes parent folder | download | duplicates (6)
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
/*  */

#include <stdlib.h>
#include <stdio.h>

int
main(int argc, const char *argv[])
{
	int			length,
				i;
	int			base,
				result;

	if (argc != 2)
	{
		printf("args: %d - random_string: length\n", argc);
		exit(1);
	}
	sscanf(argv[1], "%d", &length);

	srand(time(0));
	for (i = 0; i < length; i++)
		printf("%c", (rand() % (122 - 48)) + 48);
	printf("\n", result);
}