Ludovic 'Archivist'
By default std::vector<bool> has false right?
Initialize it with (size, true) and you are done
Ludovic 'Archivist'
Also, it is worth noting that *std::vector<bool> works differently compared to other template<typename T> std::vector*
Ludovic 'Archivist'
Like?
It is allowed to store 8 booleans per byte or any setup it likes for storing the booleans given that they are still in contiguous memory
数学の恋人
is nature a keyword in C++?
数学の恋人
ok it's not
scammer.xyz
Anybody know any idea to use c programming sockets to communicate with multiple client vice versa?
scammer.xyz
Using TCP protocol
Dima
yes
scammer.xyz
Communicate with 1 client at the time is easy
Dima
take a look on long polling
Wim
Probably he's having the issue he's responding on the port being connected to, making it unavailable to other clients
Wim
You know, Emile, you can respond from a different port on the request to keep the host-port open for multiple connections?
数学の恋人
#include <iostream> int main() { char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char oletters[] = "0123456789"; char random_name[5]; for(int i = 0; i < 5; i++) { switch(i) { case 0: random_name[i] = letters[rand() % 26]; break; case 1: random_name[i] = letters[rand() % 26]; break; case 2: random_name[i] = oletters[rand() % 10]; break; case 3: random_name[i] = oletters[rand() % 10]; break; case 4: random_name[i] = oletters[rand() % 10]; break; default: break; } } std::cout << "Random name thus generated is: " << random_name; return 0; } Please check is this program correct?
数学の恋人
Well I did
数学の恋人
I'm not getting expected results
I_Interface
and watch where it goes wrong
数学の恋人
But I was supposed to get something lke BS123 etc. etc.
I_Interface
only 5 letters not more
then watch after your algorithm
数学の恋人
use debugger
suggest me one
I_Interface
suggest me one
idk, look one for ide what u are using
数学の恋人
I'm using vim not an ide
I_Interface
hm
数学の恋人
is radare good?
数学の恋人
radare2
I_Interface
is radare good?
i didn't work with linux, sry) don't know it)
数学の恋人
Oh
Decoder_3d
So best ide is ?
I_Interface
So best ide is ?
windows - VS 2019 Mac - XCode for linux - idk)
mrphyber
emacs
It is an OS lol
mrphyber
I use it too
Anonymous
👍
Хамза
So best ide is ?
I use geany
Mihail
But I was supposed to get something lke BS123 etc. etc.
You aren't ending your string. You should add '\0' or simplly 0 once you're done writing to it.
Mihail
So cout prints it until the \0 and so you get random values after NW753 which is what your program generated
Mihail
Also that code is kinda bad
Mihail
Use 2 for's and remove the switch
Mihail
Would be way better
Mihail
Oh and seeing it's C++, just use std::string
Mihail
And rand isn't good for generating random numbers, because it's not a uniform distribution
Anonymous
yes when i tried creating a game, everytime rand gives same order of numbers.🙄
Rostin
That might be a seed problem
Nikolas
I mean, rand is not good, but it doesn't always give the same order 😆
Anonymous
That might be a seed problem
what is seed problem?
Rostin
Check what Nikolas said
Nikolas
https://en.cppreference.com/w/cpp/numeric/random/srand
Nikolas
(while the fact that rand() is not good stays true, of course)
Rostin
A "better" std alternative if mt19937
Anonymous
ok will check it out . Thanks When I googled it earlier it shows it follows a complete pattern of execution which produces same output everytime
Nikolas
srand() initializes the sequence of pseudo-random numbers that rand() gives. If you don't use srand(), it will always use 1 as seed number, so you will get always the same order
Nikolas
(this might be useful if, for example, you want to debug a program which uses rand(), since you will remove randomness from your code)
Mihail
And put it in a uniform distribution
TuF
TuF
Output?
IM
Hello everyone! I'm looking for anyone who have experience with reSIProcate, is there any1?
Mihail
Output?
Run it
Nikolas
run it and tell us
I_Interface
And put it in a uniform distribution
random_device is bad for uniform distr ? :(
Mihail
random_device is bad for uniform distr ? :(
No you give that as entropy to mt19937
Anonymous
Mihail
And then the mt19937 in a uniform distribution
Rostin
Mt19937 stands for mersenne twister
Anonymous
these things are in which library?🙄
TuF
Anonymous
Mihail
Well here's your answer
Kk
I want a personal programming tutor...anyone intrested?