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ș
Hello guys
Hello :D
(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
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ș
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
Ya Red
Usually you will use the local machine time
Ow my!! What's that? It works when I directly put it in CMD but not on c++ system function
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
Dragoș
There you can see the way I use random numbers
Liam
Implement a Mersenne Twister PRNG for yourself.
Ya Red
There you can see the way I use random numbers
Thanks very much, I needed to know how! And ur so great programmer, 👍👍
Darik
/help@GroupButler_bot
Dragoș
Thanks very much, I needed to know how! And ur so great programmer, 👍👍
Thank you. I have started programming in C++ on september. I have more examples if you want them. The only payback is that the code is half english half spanish.
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.
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
Isn't that code missing a lot of semicolons?
std::ostream& operator<<(std::ostream&, std::ostream&) is accepted, I assume.
Liam
Liam
Isn't that code missing a lot of semicolons?
Hence, syntax speaking, only one semicolon is miss.
Liam
lol
Dragoș
inchidi
Sorry mate, im already handsome :D
harry
there goes my theory, I guess
Liam
Hi Liam. I thought about this again in the shower this morning. Would you agree that bare array names only act as an rvalue pointer, but never as an lvalue?
I'm not sure, but almost yes, I guess. In sizeof(array), we pass the bare array name to the sizeof operator, however, this time array is applied as the identity of array, but not a value. Hence, sizeof(array) gives the length of the array in byte, but not the length of a pointer.
Anonymous
Ok
Wycy
Hae guys
Wycy
Hey i wanna be a good programmer guys
Liam
Glad to know.
Wycy
Work Hard!
But i am a beginner😔😔😔
Anonymous
Anonymous
When they start
Anonymous
¯\_(ツ)_/¯
Wycy
😂😂it seems complicated
Anonymous
😂😂it seems complicated
It isn't .. Open your brain and start working ..
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
😊😊😊now how do i start cause i only understand html
www.learn-cpp.org Get a basic idea from there and then see sample codes from IDEs and use the Help file of different headers
Anonymous
And challenge yourself
Anonymous
Edited the link :)
Wycy
Now with programming what do i end up creating?
Anonymous
Somethings might be easier with different languages tho
Wycy
Kinda everything
😳😳😳ok what have you created?
Anonymous
But you can pretty much do everything