Anonymous
Anonymous
int sprintf(char *str, const char *format, ...);
Anonymous
Works same way as printf but will write to str argument instead of stdout.
Buck
good, work
Buck
thanks!!
Anonymous
https://t.me/dev_community/18
Anonymous
Hello guys
Dragoș
(O_🙋_O )
hello
D
Hello guys :D
Ya Red
Hi guys👋👋👋
Ya Red
I need help, I've included stdlib.h and have used the system() function to do things on cmd
Darik
Can any one of u have working calendar code please guys I really need it
Dragoș
Ya Red
But, it's different here, the %random% is hardly random and I couldn't create a file or folder even with the right code! Is c++ defective or is there a solution?
Dragoș
Ya Red
Dragoș
The seed is the starting point the random generator engine uses
Dragoș
Usually you will use the local machine time
Ya Red
I just wrote echo %random% with a loop, but it only changes number after 10 numbers
Dragoș
I have been tought to use
srand(time(NULL)); to start the engine and then assign the value rand() to a variable
Dragoș
Here is a blackjack minigame i had to do in C++ as homework
https://pastebin.com/yqVbq5WH
Ya Red
Dragoș
There you can see the way I use random numbers
Dragoș
Liam
Implement a Mersenne Twister PRNG for yourself.
Darik
/help@GroupButler_bot
Ya Red
Thanks, but I think I might get what I need at my lvl with all English
Ya Red
But this random thing, thanks for showing me
Dragoș
Good luck :D
Ya Red
Liam
There you can see the way I use random numbers
carta = rand()%12+1; is simply wrong.
rand() produces random nurmbers between 0 and RAND_MAX, which is 32767 in most systems. Since 32767 is coprime to 12, rand() % 12 will never be uniformly randomly.
Dragoș
Liam
I didn't know that. How could I solve that problem?
Since you're using C++, try:
#include <random>
namespace {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 12);
} // namsepace
// application codes
std::cout << dis(gen) << std::endl; // iostream required.
Dragoș
I have basic knowledge about programming. I will try to comprehend that code tomorrow
Dragoș
Thank you for the advice
Liam
carta = rand()%12+1; is simply wrong.
rand() produces random nurmbers between 0 and RAND_MAX, which is 32767 in most systems. Since 32767 is coprime to 12, rand() % 12 will never be uniformly randomly.
Since 32767 / 12 = 2730 and 32767 % 12 = 7, for every 32767 generations, 1, 2, ..., 7 will have one time more than 8, 9, ..., 12.
If you loop them with enough times, say 1,000,000 times, you'll find the uniformness is broken. @ccobre
Darik
Can any one of u help me out with this problem
Darik
Darik
I can't seem to understand it
Liam
Liam
The compiler error message helps you.
Dragoș
Isn't that code missing a lot of semicolons?
Liam
Liam
lol
Dragoș
inchidi
Sorry mate, im already handsome :D
harry
Liam
harry
there goes my theory, I guess
Anonymous
Ok
Wycy
Hae guys
Wycy
Hey i wanna be a good programmer guys
Anonymous
Liam
Glad to know.
Anonymous
Anonymous
When they start
Anonymous
¯\_(ツ)_/¯
Wycy
😂😂it seems complicated
Anonymous
Most importantly .. Make your own algos
Anonymous
So that things go in flow for you
Anonymous
Others might think differently so you won't always understand it and claim the code to be complicated
Wycy
😊😊😊now how do i start cause i only understand html
Anonymous
And challenge yourself
Wycy
Anonymous
Wycy
Now with programming what do i end up creating?
Anonymous
Anonymous
Somethings might be easier with different languages tho
Anonymous
But you can pretty much do everything