Anonymous
You meant binary?
Yes, it's binnary
Iwan
biner. binary
Iwan
I think it is time for me to leave this group. I dont like this stupid timer. Bye² all.
Jillur Rahman
How can I use logarithms when I have to find the product of 4 variables (each variable is having a maximum possible range of 1e9)?
Chat Boss
𝕂𝕦𝕤𝕙𝕒𝕘𝕣𝕒 🏳️‍🌈 sent a huge message, it has been re-uploaded as a file i recently started learning c, and was working on a program to swap variable values. i created t..
klimi
^ you are just swapping pointers, not the values, so the program just does what you have told it
Abdul
#include <stdio.h> #include <stdlib.h> int main(void) { int a; print("Enter a number"); scanf("%d",&a); printf("you have entered %d",a); return EXIT_SUCCESS; }
Abdul
#include <stdio.h> #include <stdlib.h> int main(void) { int a; print("Enter a number"); scanf("%d",&a); printf("you have entered %d",a); return EXIT_SUCCESS; } plz tell me , how to solw it
April
the first "print"
April
The parameters of the main function are entered from the command line terminal
kj
What there doing "void", can someone explain? (it's not a nitpick)
basically implies that the main function will NOT take any arguments, even if you provide it.
Anonymous
not double n
I mean binary, sorry😁
Mitesh
Hi all, https://github.com/mitesh-gohel/queries/blob/main/t2.c Can anyone help me to understand behaviour of this code ?
Konstantin
Hi all, https://github.com/mitesh-gohel/queries/blob/main/t2.c Can anyone help me to understand behaviour of this code ?
"For unsigned numbers, the bit positions that have been vacated by the shift operation are zero-filled. For signed numbers, the sign bit is used to fill the vacated bit positions. In other words, if the number is positive, 0 is used, and if the number is negative, 1 is used." so -1 as b11111111 after ">> 1" will be the same b11111111 which equal -1
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
guys read and write, when used for TCP socket communication, return -1 on error, right? For istance, server-side is stuck on a read, client-side the client closes the socket (close(client_socket) and exits (exit(0)). Well, the read server-side should return -1, right? Well, it returns 0 to me... and I'm not quite sure why this happens. Do you have any ideas? The code is for POSIX systems, but I'm coding on windows, I use WSL for terminal and gcc to compile.
Kay
Can everyone explain what the system ("pause") function is?
Anonymous
guys read and write, when used for TCP socket communication, return -1 on error, right? For istance, server-side is stuck on a read, client-side the client closes the socket (close(client_socket) and exits (exit(0)). Well, the read server-side should return -1, right? Well, it returns 0 to me... and I'm not quite sure why this happens. Do you have any ideas? The code is for POSIX systems, but I'm coding on windows, I use WSL for terminal and gcc to compile.
Can't you check the documentation? A read() call on a socket is equivalent to a recv() call without any flags. Here is a quote from the documentation for recv() for your use case. When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file" return). In future, learn to read the documentation.
Konstantin
For signed integers, >> has implementation defined behavior. It is not always the case that the sign bit is used.
I couldn't find mentions about this dependency. But also I am a not a c or c++ programmer. I found Draft n4835 which says in 7.6.7-3: The value of E1 >> E2 is E1/(2^E2), rounded down. [Note: E1 is right-shifted E2 bit positions. Right-shift on signed integral types is an arithmetic right shift, which performs sign-extension. — end note]
Anonymous
I couldn't find mentions about this dependency. But also I am a not a c or c++ programmer. I found Draft n4835 which says in 7.6.7-3: The value of E1 >> E2 is E1/(2^E2), rounded down. [Note: E1 is right-shifted E2 bit positions. Right-shift on signed integral types is an arithmetic right shift, which performs sign-extension. — end note]
You are looking at the C++ Standard while code is in C. Even in C++, the right shift operation was implementation defined until C++20 and it was made an arithmetic shift with sign extension only in C++20 (you are referring to the draft copy for the standard after this change). Here is the quote from Cppreference: For negative a, the value of a >> b is implementation-defined (in most implementations, this performs arithmetic right shift, so that the result remains negative). (Pre C++20) The value of a >> b is a/2b , rounded down (in other words, right shift on signed a is arithmetic right shift). (Since C++20) In C however, right shifts on a negative integer is Implementation Defined Behavior while left shift on a negative integer is Undefined Behavior.
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Can't you check the documentation? A read() call on a socket is equivalent to a recv() call without any flags. Here is a quote from the documentation for recv() for your use case. When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file" return). In future, learn to read the documentation.
That's right, my professor anyway says that it must return -1 when client collapses. Which is very strange, since when the client abandons in an unpredictable way it must return -1 as it is an error, but if all writing process correctly close the connection on the client side, then it returns 0. But my professor insists it returns -1 anyway, that's the reason of my question. When I hit the client with CTRL+C the client will close socket, and on the other side the server, stuck in the read, will return Errno= 0 Streerror(errno)= SUCCESS and i really don't know if it is correct, but I take it as SUCCESS means that on the other side the channel was properly handled
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
At this point I think we had a misunderstanding, as the documentation is very clear and even in his papers, when talking about PIPEs, he says that a read call returns 0 when all writers processes correctly close the pipe on the other side
Llll
Hello guys, I am experiencing problems trying to make intellisense and MSVC compiler recognise includePaths for my ns3 simulation c++ code. Running the compilers throws errors that the header files cannot be found, and intellisense shows red squiggly lines under the specified headers.
Llll
I have specified the headers in the c/c++ compiler configuration in the .vscode folder but nothing seem to work.
Ziky
There might be something like include paths but I am not Ms fan
Llll
Yes, I specified it but intellisense happens to ignore it
Chat Boss
Dαɾƙ Tαɳɠҽɳƚ sent a code, it has been re-uploaded as a file
Anonymous
Dαɾƙ Tαɳɠҽɳƚ: Sample Input 2: 2 9 1 3 6 2 5 4 3 2 4 12 6 2 8 10 5 -2 5 10 Sample Output 2: 0 2 when i do second testcase then it is showing 3 as output instead of 2
Ziky
If you can see compiler commands somewhere check if it is set there https://learn.microsoft.com/en-us/cpp/build/reference/i-additional-include-directories?view=msvc-170
Llll
I have ns3 installed built on wsl on windows and I am interfacing it using vscode from windows through a mapped UNC address to the wsl virtual drive
Anonymous
Dαɾƙ Tαɳɠҽɳƚ sent a code, it has been re-uploaded as a file
Dαɾƙ Tαɳɠҽɳƚ: Sample Input 2: 2 9 1 3 6 2 5 4 3 2 4 12 6 2 8 10 5 -2 5 10 Sample Output 2: 0 2 when i do second testcase then it is showing 3 as output instead of 2
Anonymous
Pls someone help
Ziky
I think you are breaking the rules
Ziky
Don know wat it is supposed to do for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(sum==arr[i]+arr[j]){ pair++; } } } but try to put arr[i]+arr[j] into parenthesis
Anonymous
It is not wrong because there are two test case first is right but in second when it is printing 3 but the right answer is 2
Ziky
hmm ok addition seems to have priority over comparison
Ziky
at least at onlinegdb :D
Ziky
I guess you might want to exclude cases when i==j
Ziky
But i have no idea what is your code supose to do
Anonymous
could you describe the "statement" ?
Bro I can't send photo of the question in grp
Mahmoud
Hello
Mahmoud
As I see in many sources the code of depth first and breadth first but I didn’t understand the code well any suggestions from where I can understand well the code of depth first and breadth first . Thank you !
Rahul
How to ise thread library in with mingw compulier i have getting an error
Anonymous
How to ise thread library in with mingw compulier i have getting an error
What thread library? C or C++? What is the error?
Anonymous
As I see in many sources the code of depth first and breadth first but I didn’t understand the code well any suggestions from where I can understand well the code of depth first and breadth first . Thank you !
Learn the programming language that you like to read code in well first. Then learn about DFS and BFS along with other graph algorithms. Now look at the code again.
soheil
i install clang from script in their site - but now terminal cant find clang and cant run in terminal
soheil
i install clang from script in their site - but now terminal cant find clang and cant run in terminal
Command 'clang' not found, but can be installed with: sudo apt install clang
soheil
klimi
i find it - i must type clang-15
I am curious, why have you installed it from their site and not from the repositories?
klimi
because in repo is clang version 11
ah, understandable; thanks :)
Anonymous
because in repo is clang version 11
???? If the repo is 11 where do you think Clang 15 was built from? Not sure which repo you are looking at
Anonymous
you must add 15 to end of all pacakges
I have Clang built from the llvm compiler infrastructure repo and I have the latest version of Clang.
soheil
everyone do it with different methods
Anonymous
they are probably on some stable or old debian or something
You can build clang-15 from the repo even on a very old Debian distribution. LLVM just expects a C+11 compiler to build Clang (not sure if it has been upgraded to C++14 now)
Anonymous
well but then you _have_ to compile it and not just download it no?
Yes. But you can then upgrade to later versions easily. With the script you have to wait for it to be made available. The same with your distro's package managers.
Danya🔥
And actually it needs C++17 now
Anonymous
And actually it needs C++17 now
C++17 is with LLVM 16. That I know for sure. For 15, it works with C++14. I thought they would move from C++11 directly to C++17. No point in switching to C++14 which had very minor additions on top of C++11