delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/22/22:59:58

From: naytheeus28 AT aol DOT com (NaytheeUs28)
Newsgroups: comp.os.msdos.djgpp
Subject: Randomizing char
Lines: 72
NNTP-Posting-Host: ladder07.news.aol.com
X-Admin: news AT aol DOT com
Date: 23 Jan 2000 03:33:13 GMT
Organization: AOL http://www.aol.com
Message-ID: <20000122223313.02660.00000994@ng-cu1.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Im so really stuck.i want to make a name generator. but my output wont produce
anything. and im getting callback error messages.

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

 int rnd(int range);
 void seedrnd(void);
 char get_character_name(char *string);

 char *pri[17]; /* is there any way to declaire a variable with a randomized
setting
                        i don't want it to always be at this number */
 int main()
  {
   seedrnd();

   get_character_name(*pri);
   printf("%s",*pri);
  }

 int rnd(int range)
  {
     int r;
     r=rand()%range;
     return(r);
  }
 
 void seedrnd(void)
  {
    srand((unsigned)time(NULL));
  }

 char get_character_name(char *string)
  {
    char *g_name_size[16];
    char z[] = {65,69,73,79,85};
    char a,b;

    int h,t,w;

     a=0;
     b=0;

       for(h=1;h<4;h++)
        {
         for(t=1;t<16;t++)
          {
      start1:
             a=65+(rnd(25)+1);
             w=rnd(1);

               if(w<.7 && a==69 || a==73 || a==79 || a==85)
                goto start1;

               if(t==2 || t==5 || t==7)
                b=z[rnd(4)+1];

               if(b!=0)
                 g_name_size[t] = b;
          }
        g_name_size[t] = a;
        }
        *string = *g_name_size[t];
        return(*string);
  }


i got it to exit at 0x0000 but when i ran the .exe the screen filkered and then
the window cloesed :(
im almost bald any help would be most appreciated. 
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019