MRT
do { printf(" READY \n"); ClientSocket = accept(ListenSocket, NULL, NULL); if (ClientSocket == INVALID_SOCKET) { printf("accept failed with this fucking Error: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; } HandShakeThreadClass *_handShakeThread = new HandShakeThreadClass(&ClientSocket); _handShakeThread->StartInternalThread(); continue; } while (is_active);
MRT
after i declare class in there HandShakeThreadClass *_handShakeThread = new HandShakeThreadClass(&ClientSocket); _handShakeThread->StartInternalThread(); » ClientSocket memory address not changed in while
MRT
all ClientSocket have a same memory address
MRT
why ?
Anonymous
why ?
Why not?
MRT
Socket should not have different addresses ?
MRT
socket accept from clients
Anonymous
In this case not, because you basically using the same variable
MRT
srry for wrting bad english
Anonymous
problem is do while ?
The problem is that you're using the same variable allocated on stack
MRT
im new in c++, you can fix my code to better understand ? ! thank
Henry
Please which is good programming c in linux or window
Anonymous
Please which is good programming c in linux or window
What is the "programming c"?
Henry
Like programming in c
Anonymous
Like programming in c
Learn some English
Henry
Writing c though
Anonymous
Writing c though
What "writing c"?
Henry
What "writing c"?
Okay i think you understand what i want to say
Henry
Like 😔 writing codes in c programming language
MRT
😂
Stay Forward
/saved
Andrey
/notes
Henry
/note
Henry
/notes
🇵🇭🇷🇺
My mother taught me to defend myself, because no one has the right to judge somebody. There is only one lawgiver and judge, he who is able to save and to destroy. It's God 👆
🇵🇭🇷🇺
Please stop with off topic. Thanks
You're welcome. Titan👽
Roxifλsz 🇱🇹
/warn offtopic, this is not a youtuber group lol
Anonymous
Guys why doesn't this condition work when x=0, if (x<1 || x>8) return 0;
Anonymous
It works when x is negative but not for x=0
Anonymous
Any negative number or number greater than 8 activates the condition
Pavel
Guys why doesn't this condition work when x=0, if (x<1 || x>8) return 0;
What is the type of x? Are you sure that the issue in this code and not in some code before?
Anonymous
int x , no; cin >> x; while(x) { if ( x < 1 || x >= 1500) return 1; else no *= 10; }
Anonymous
In this code snippet, when x = 0, the code doesn't work as expected
Anonymous
int x; cin»x;
Anonymous
int x; cin»x;
Sorry, forgot to add that
Anonymous
Assuming that the while condition had any other variable apart from x, then the if condition works for x= 0
Anonymous
works perfectly well for me
Anonymous
Yeah but not for x=0
The code does not return 1 when x = 0
Anonymous
tested for 0 and it works. something else in your code. this is not it
Anonymous
Not really, using code blocks as my ide
Anonymous
ah for 0 it does not enter the while
Anonymous
But for 1, it enters
Anonymous
I mean it works perfectly. for 0 the loop exits.
Anonymous
returns whatever is outside the while loop...0 does not trigger the while condition
Anonymous
Now, that I am thinking about it, the code is a total aberration. By the condition stated in the while loop, the code should always return 1 because x will at some point be 0. The code therefore is a total mess
Anonymous
:)
Anonymous
I meant x will always end up being 0 for any positive number in the range. So the behavior it's displaying is totally unexpected. Especially for not continuing with the loop when x=0 and simply just executing statements outside the loop for x= 0
Anonymous
Instead, the solution should be the conditional if else statement with the nested while loop
Anonymous
I meant x will always end up being 0 for any positive number in the range. So the behavior it's displaying is totally unexpected. Especially for not continuing with the loop when x=0 and simply just executing statements outside the loop for x= 0
Now, I get the reason for the behavior. It is because a counter controlled while loop is designed to break for counters being equal to 0. Thus with x being my counter, setting x to be 0 prior to loop execution will simply cause the loop to not run as the loop's breaking condition has been met in advance.
Pavel
The code does not return 1 when x = 0
Because with x==0 you don't enter the loop
Anonymous
Thanks
inkfil
/cpp
Ikha
/cpp
Vedant
/cpp
inkfil
/cpp
Огни
/cpp
Nils
struct Variable { enum Type { id_string, id_integer, id_reference } type; union Data { std::string string; int32_t integer; Variable *reference; } data; }; Any idea why I get "call to implicitly-deleted default constructor" when tring to use this struct?
labyrinth
string in a union is kind of weird isn’t it?
Anonymous
Use std::variant
Anonymous
It's less error prone and more convenient
Anonymous
using Variable = std::variant<std::string, int64_t, Variable*>;
labyrinth
But I don’t get the reason why it says implicitly deleted default constructor
Anonymous
But I don’t get the reason why it says implicitly deleted default constructor
If a union contains a non-static data member with a non-trivial default constructor, the default constructor of the union is deleted by default unless a variant member of the union has a default member initializer.