l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2002 Jan 31 23:26

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] [C newbie]C program is acting weird...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] [C newbie]C program is acting weird...



What do you *want* it to do?

Including numbers will need some math trickery.  The place with 'z' and
'a' is where it's picking a letter between 'a' and 'z', but since numbers
aren't in a sequential order in the ASCII system, you can do something
like expanding the range and 'if'-ing the range for a letter or number.

-Mark

On Thu, 31 Jan 2002, Ryan wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> for some reason this is spitting out 3 char responses once in a while, anyone
> have any ideas? I don't know much C, this is just some code I modified.
>
> Also, if anyone knows how to get it to include numbers mixed in with the
> letters i'd like to know how.
> - ------
>
> #include <stdio.h>
> #include <sys/types.h>
> #include <unistd.h>
> #include <signal.h>
> #include <stdlib.h>
> #include <time.h>
> #include <string.h>
>
> #include "version.h"
>
> #define SESSION_TIMEOUT 20
>
> #define MAX_RESPONSE 200
> #define MAX_REQUEST 100
>
> #define MIN_LEN 4
> #define MAX_LEN 9
>
> char *randusername()
> {
>         char *string;
>         int i, length;
>         // randomly choose a length betweem MIN_LEN and MAX_LEN
>         length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;
>         if (string = malloc(length + 2), string == NULL)
>                 return NULL;
>         for (i = 0; i < length; i++)
>                 // does your head hurt yet?
>                 string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));
>         // zero terminate!
>         i++;
>         string[i] = '\0';
>         return string;
> }
> - --
> No Microsoft products were used in any way for the creation of this message.
> PGP Public key at http://mother.com/~ryan/ryan_at_mother_dot_com.asc
> It is also on the servers: Key ID 0x72177BC7
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iD8DBQE8WjuYEd9E83IXe8cRArkBAJ9KZAmEZrqQbbBWY0MBv6EFid9ZRACfXKDc
> G2u947jK74bVhkLKjjEPsIg=
> =kHSN
> -----END PGP SIGNATURE-----
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
>

--
Mark K. Kim
http://www.cbreak.org/mark/
PGP key available upon request.

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.