Then use a different seed each time, e.g., by seeding based on the current time, or from a random source like /dev/random.Quote:
Originally Posted by Alexz003
Printable View
Then use a different seed each time, e.g., by seeding based on the current time, or from a random source like /dev/random.Quote:
Originally Posted by Alexz003
what? xP i have no idea what you said.
Code:std::srand(std::time(0));
My advice is that you start writing programs. Just think of a program that does something interesting and then start writing it. This has the advantage that you're shifting focus from learning C++ features you don't don't know what they're for, to wanting to do something and is looking for a proper C++ feature to do that. It's a problem based approach. You're looking to solve problems rather than having solutions you don't know what they're for.
Good luck!
In addition to my post above:
Why don't you learn from Bjarne Stroustrup, the inventor of C++? He's very recently published a book called Programming, Principles and Practices Using C++. It contains lots of drills, reviews and exercises after each chapter.
Quote:
But the thing about it is i don't want it to repeat the same thing i want it to be random each time.
Code:
std::srand(std::time(0));
what would that do?
If you search for examples related to the documentation on srand and on time, you'll see that srand initializes the random number generation system, and that if you use a different number on each call to srand, the random numbers generated by rand will be different on every execution of the application.
One minor flaw is that time is usually measured in seconds. You call srand at the initialization of a program. That sets the random generator to a unique output.
The next time the application runs, srand will receive a different time, and different number to initialize the random generator - no to runs of the application will obtain the same series of numbers from rand..
The only exception could be if two executions of the same program happen within 1 second of each other. Note, that's not two calls to rand, that's any two calls to TIME - it counts in seconds. As long as srand is called a little over 1 second later than the previous call, the random generator will be seeded such that a unique sequence comes out of rand - never the same twice.
Alexz003, please try harder to follow. Google for the C or C++ library and read some of the documentation for the suggestions we're posting - the only way any of us ever learned this stuff (myself included) was to research and dig.
Please don't misunderstand, this IS the place to ask questions - I'm just saying that in this case, after being handed the answer, it seems you haven't been interested enough to research that yourself or try it on your machine.
I wouldn't have asked if i wasn't getting what i was looking for. I have looked it up and tried what people have said worked and i always get the same result.
I think we are going off topic and i would like to redirect the question back to my first post if you don't mind.
I want to learn how to influece what the computer does not what my variables do.
I suppose I'm not exactly sure what this means, but I have some idea.Quote:
I want to learn how to influece what the computer does not what my variables do.
Much of develop is the creation of metaphors which represent real concepts, real objects and the like. Interaction seems to be what you're describing.
That could be the interaction of a server responding to connections, searching for and providing data upon request.
It could be the reaction of a character in a game.
I think we're still searching for something a little more concrete upon which to base the discussion.
I know im sorry i haven't been real specific on what i want. It isn't completely my fault because i haven't learned enough to actually know what i want to do. Thats why i am requesting people give me ideas on something that would teach me a little more than i already know. I have no idea what it may be as long as it isn't too complicated and i can understand what i am doing.
i may be passive but that doesn't mean i wont know what to do in the future. If i have a project in mind then i will do what i can do get it done.
I have made 2 programs. 1 is a game and the other is something that lets me get to all important programs that i use on my computer with ease.
I think you might be a little stressed.