Article View: comp.os.ms-windows.programmer.tools.mfc
Article #157Re: REQ : How to make random number in MFC?
From: Joshua Waxman
Date: Mon, 10 Aug 1998 00:00
Date: Mon, 10 Aug 1998 00:00
20 lines
1880 bytes
1880 bytes
On Mon, 10 Aug 1998, Euntaek Woo wrote: > How can I make 1-digit integer random number in MFC? > Unlike Borland C or C++, the function 'random' doesn't work. > How can I do? > Thanx. > The trick is to stay within the realm of standard C. That way it will work in every platform: srand(time(NULL)); int r = rand() % 10; // range of 0 to 9 Look up these standard functions in your online help. Also, see the C faq for information on how to achieve more random results using these standard functions. Hope this helps. Josh Waxman
Technical Details
Message-ID:
<Pine.A41.3.95.980810062551.102722A-100000@acis.mc.yu.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<ph2nG1Cx9GA.219@news4.netsgo.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f4d60,7a76dcfef6a35ba4 X-Google-Attributes: gidf4d60,public X-Google-Thread: 1138df,7a76dcfef6a35ba4 X-Google-Attributes: gid1138df,public X-Google-Thread: f7a51,7a76dcfef6a35ba4 X-Google-Attributes: gidf7a51,public X-Google-Thread: f58d1,7a76dcfef6a35ba4 X-Google-Attributes: gidf58d1,public X-Google-Thread: 10ef8f,7a76dcfef6a35ba4 X-Google-Attributes: gid10ef8f,public X-Google-Thread: fffac,7a76dcfef6a35ba4 X-Google-Attributes: gidfffac,public X-Google-Thread: 104d65,7a76dcfef6a35ba4 X-Google-Attributes: gid104d65,public X-Google-Thread: f959c,7a76dcfef6a35ba4 X-Google-Attributes: gidf959c,public From: Joshua Waxman <jwaxman@ymail.yu.edu> Subject: Re: REQ : How to make random number in MFC? Date: 1998/08/10 Message-ID: <Pine.A41.3.95.980810062551.102722A-100000@acis.mc.yu.edu> X-Deja-AN: 379657499 References: <ph2nG1Cx9GA.219@news4.netsgo.com> X-Sender: jwaxman@acis.mc.yu.edu Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: Yeshiva University Mime-Version: 1.0 Newsgroups: comp.os.ms-windows.programmer.tools.mfc,han.comp.lang.c,han.comp.lang.c++,han.comp.lang.misc,han.comp.os.ms-windows.programming.misc,microsoft.public.vc.language,microsoft.public.vc.mfc,microsoft.public.vc.mfcole,microsoft.public.vc.online_help