Ritwik
But it prints wrong
Ritwik
Where is the mistake
Ritwik
??
Anonymous
Here, is the addresses of a and b the same? Or 'b' with a different address from 'a' contains the address of 'a' ?
Also, & performs different operations on the context that you use it, it can return the address or pass a reference. Which is a little confusing. Also it's a bitwise operation in another context.
Anonymous
Modulo is evil use divide
Anonymous
while(i<=500); getch(); Are you for real? wtf?
Anonymous
What are you doing that for?
Anonymous
is that a do while?
Anonymous
why is there no do at the beginning?
Anonymous
do { } while();
Anonymous
i've never seen some one use while at the end of a statement
Ritwik
do { } while();
Sorry I forget to write that..
Anonymous
while() { }
Anonymous
np i was just confused
Anonymous
looked like you where trying to loop getch() 500 times
Ritwik
np i was just confused
Can you found where is the problem
Anonymous
hows it not working? the result number
Anonymous
Honestly I have no idea why your armstrong algo is not working, i'm not going to compile it for you atm but I suggest making print() breakpoints to output each stage of the calculation until you find the step where it goes wrong
Francisco
We really prefer a code snippet right in Telegram or a link to the code via pastebin, compiler explorer, etc
Dima
Found a good article, yeah it’s kinda old but still https://www.gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine
Anonymous
The compiler you are using matters most but don't know where to get compiler to download.
Dima
what’s practical difference between SO_REUSEPORT and SO_LINGER?
Dima
like… docs almost identical, or I am missing something
Ибраги́м
what’s practical difference between SO_REUSEPORT and SO_LINGER?
SO_REUSEPORT (since Linux 3.9) Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. This option must be set on each socket (including the first socket) prior to calling bind(2) on the socket. To prevent port hijacking, all of the pro‐ cesses binding to the same address must have the same effec‐ tive UID. This option can be employed with both TCP and UDP sockets. For TCP sockets, this option allows accept(2) load distribu‐ tion in a multi-threaded server to be improved by using a dis‐ tinct listener socket for each thread. This provides improved load distribution as compared to traditional techniques such using a single accept(2)ing thread that distributes connec‐ tions, or having multiple threads that compete to accept(2) from the same socket. For UDP sockets, the use of this option can provide better distribution of incoming datagrams to multiple processes (or threads) as compared to the traditional technique of having multiple processes compete to receive datagrams on the same socket.
Ибраги́м
SO_LINGER Sets or gets the SO_LINGER option. The argument is a linger structure. struct linger { int l_onoff; /* linger active */ int l_linger; /* how many seconds to linger for */ }; When enabled, a close(2) or shutdown(2) will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise, the call returns immediately and the closing is done in the background. When the socket is closed as part of exit(2), it always lingers in the background.
Ибраги́м
Not So the samey
Dima
Wait.. I must have been reading the same docs lol
Daniel
Hi guys! Wtf is this? https://github.com/RXDYE/oopLab6 I get undefined reference error when function is defined in cpp-file. When it's defined in header but OUT of the class linker see it.
Pavel
Yep, with template function/class you need to put implementation in the same translation unit (in your case in header), to let the compiler to generate the code; or to have implementation for specific types, in this case it's working like usual function/class.
BinaryByter
>compiler knows address of every local variable are you drunk?
BinaryByter
local variable adresses aren't known at compile time
BinaryByter
neither are global variable adresses
BinaryByter
Umm
BinaryByter
this isn't a variable adress
BinaryByter
this is merely an offset
BinaryByter
Or rather: how do you know where in memory the program is loaded?
Daniel
wow. Thank you guys
BinaryByter
in this case, the global variable is an offset
BinaryByter
the linker will mark it as an offset at linkage
BinaryByter
and the kernel will fill in the gap when loading the executable
Anonymous
Hi
🐰🐾 سمیه
what's lvalue?
BinaryByter
its a variable
BinaryByter
try *(++y)
olli
what's lvalue?
n1570 - 6.3.2.1 An lvalue is an expression (with an object type other than void) that potentially designates an object; if an lvalue does not designate an object when it is evaluated, the behavior is undefined. [...]
🐰🐾 سمیه
n1570 - 6.3.2.1 An lvalue is an expression (with an object type other than void) that potentially designates an object; if an lvalue does not designate an object when it is evaluated, the behavior is undefined. [...]
incrementing a pointer by ++ operator, increments its value, which is an adress, by 1. In contrast, incrementing by number ( like y+1, and y is a pointer), makes it to point the next object ( char or int ... etc.). true?
🐰🐾 سمیه
🐰🐾 سمیه
error
🐰🐾 سمیه
here for ++y, I got below error. but by replacing it with *(y+1), it printed string b.
olli
incrementing a pointer by ++ operator, increments its value, which is an adress, by 1. In contrast, incrementing by number ( like y+1, and y is a pointer), makes it to point the next object ( char or int ... etc.). true?
y is an array or char pointer (hence cannot be incremented) 6.3.2.1 further states [...] A modifiable lvalue is an lvalue that does not have array type [...]
Pavel
here for ++y, I got below error. but by replacing it with *(y+1), it printed string b.
In addition, ++y and y+1 do different things, first is modifying value of y
olli
and second?
does not change y and instead yields a temporary
olli
it's the same with int x = 3; ++x; // increments x (so x is 4) int y = x + 1; (does not change x but adds 1, so y is 5)
🐰🐾 سمیه
in case of pointers, y +1 points to the next object of its type. right?
🐰🐾 سمیه
yes
So, why here at the above and below arrows, it walks through the elements by ++ operator?
🐰🐾 سمیه
or for example in copy fuction void copy( char *s, char *t ) for ( ; *s = *t; s++, t++);
🐰🐾 سمیه
🐰🐾 سمیه
I'm badly confused😟
Pavel
So, why here at the above and below arrows, it walks through the elements by ++ operator?
Well, this is a bit different You have a pointer to array of three elements of type char* In the example you've sent it's basically a char** (because the size is not given). In the memory it will be the same thing, but compiler knows more information in your case and can prohibit you of doing some unsafe things with the pointer. I'm not actually familiar with C-style arrays, so I may be wrong (hope I will be corrected by other uses then). But reading your code I assume that incrementing the pointer there makes no sense.
🐰🐾 سمیه
yes argv is of type cahr **
🐰🐾 سمیه
but how that explains the starnge behaviour?
Anonymous
Hey...is it possible to input elements in array by recursion and not by for loop
Pavel
but how that explains the starnge behaviour?
Oh, I see that I was wrong and y is an array of pointers, not pointer to an array (as olli had written already but I missed it also)
Francisco
Hey...is it possible to input elements in array by recursion and not by for loop
Why would you? And if it's assignment, you should be able to do it
Pavel
So array cannot be incremented, but you can get a pointer to the first element and increment it
Pavel
But instead you can just get elements by index, that would be much clearer way of doing the same thing :)
🐰🐾 سمیه
But instead you can just get elements by index, that would be much clearer way of doing the same thing :)
true, in the above example why argv is of type char **. and what that means?
🐰🐾 سمیه
the argumet of main says it has to be of type char * not double star!
🐰🐾 سمیه
?
an English speaking Russain, with arabic profile. seems funny😊
Mihail
the argumet of main says it has to be of type char * not double star!
Both char** argv char* argv[] would work as arrays decay into pointers