Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 118,860 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,677 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Generating Random Numbers in C

 
Reply to this topicStart new topic

Generating Random Numbers in C, C Programming

Ricendithas
post 18 Jul, 2008 - 11:02 PM
Post #1


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 32


My Contributions


The number being generated is the same everytime, how will I be able to randomize the numbers? Thanks.

c

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

int main(void) {
printf("%d", rand());

getch();
return 0;
}


This post has been edited by Ricendithas: 18 Jul, 2008 - 11:03 PM
User is offlineProfile CardPM

Go to the top of the page


NickDMax
post 18 Jul, 2008 - 11:13 PM
Post #2


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,763



Thanked 37 times

Dream Kudos: 525
My Contributions


see srand()
User is offlineProfile CardPM

Go to the top of the page

Ricendithas
post 19 Jul, 2008 - 12:05 AM
Post #3


New D.I.C Head

*
Joined: 12 Jul, 2008
Posts: 32


My Contributions


QUOTE(NickDMax @ 18 Jul, 2008 - 11:13 PM) *



Thanks for the info. It is now working.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 10/13/08 01:43AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month