Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-19-2004, 10:48 AM   #1 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 59
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
random numbers

how to get a totally random number every time the program is run.

here is some code

Code:
cout << array[0 + rand() % 12] << " | ";
the array has 12 strings in it, and i need it to print a random one.
Rotkiv is offline   Reply With Quote
Old 07-19-2004, 06:26 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
you are calling srand() at some point, i would hope. otherwise, your code seems fine.

you do realize that 0 + <some number> = <some number>, right?
joe_bruin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Variable Numbers falsepride HTML, XML, Javascript, AJAX 1 10-28-2004 01:23 PM
adding numbers doesn't add up !!! help arwilliams HTML, XML, Javascript, AJAX 3 09-30-2004 10:17 AM
Quick way to select a random array element? Epsilon PHP 4 03-11-2004 04:49 PM
format numbers sde PHP 3 10-03-2002 11:10 AM


All times are GMT -8. The time now is 05:38 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting