File: random_string.c

package info (click to toggle)
slony1-2 2.0.4-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,716 kB
  • ctags: 4,089
  • sloc: ansic: 17,784; sh: 12,592; xml: 8,185; sql: 7,314; yacc: 2,468; perl: 2,376; lex: 1,321; makefile: 909; awk: 24
file content (25 lines) | stat: -rw-r--r-- 435 bytes parent folder | download
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
/* $Id: random_string.c,v 1.3 2008-05-26 18:24:21 cbbrowne Exp $ */

#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);
}