home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,650 of 243,242   
   Michael Sanders to Keith Thompson   
   Re: srand(0)   
   31 Dec 25 04:51:11   
   
   From: porkchop@invalid.foo   
      
   On Tue, 30 Dec 2025 19:35:12 -0800, Keith Thompson wrote:   
      
   > Summary: Some systems guarantee that argc>=1 and argv[0] points to   
   > a valid string, but software that's intended to be portable should   
   > tolerate argc==0 and argv[0]==NULL.   
   >   
   > For more information, see   
   > .   
      
   Thanks Keith so I'll roll with ISO:   
      
   int main(int argc, char *argv[]) {   
      
       // ISO: if app named 'moo' play bulls & cows else mastermind   
       const char *p = (argc > 0 && argv && argv[0]) ? argv[0] : "";   
       const char *m = strrchr(p, '/');   
       MOO = strcmp(m ? m + 1 : p, "moo") == 0;   
      
       int s = get_seed(argc, argv); // returns default seed if not supplied   
      
       fflush(stdout);   
       fprintf(stderr, "%d\n", play(s)); // print seed to stderr   
      
       return 0;   
   }   
      
   --   
   :wq   
   Mike Sanders   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca