Suka
Hello? I am new learning C++, how to code it Ubuntu?
install build-essential package group. and cmake if you're familiar with it. then install ide or editor like vscode.
Jillur Rahman
I am a C beginner.I have solved 200+ problems so far of data types,conditional statements,loop and some array and string as well.Now I want to shift to C++.How can I do it now in the most possible productive way?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
hi, in a client server application with TCP sockets, should I use read/write or recv/send? Both my server and my client use signal handling with sigaction, for istance CTRL+C shuts down the server istantly; The client also uses fgets to take input. What I want is that, no metter if in read from/write on socket operation (both Client and Server) or if in a fgets operation (client), when a signal arrives, the signal must be handled. I hear that recv/send can be made non blocking, is this enough to solve my problem?
رغد🖤
Hello, can any of you tell me how he became good with C Plus, what was his step that he took? I do a lot, but unfortunately I make a lot of mistakes
رغد🖤
C++
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
yes it is, it's been set with sigaction in the main of the software, therefore it should always be ready to kick in when needed, it's just that sometimes it doesn't
Vitor
Hello guys, im new to C and i want to know how to read an enviroment variable from a .env file
klimi
Hello guys, im new to C and i want to know how to read an enviroment variable from a .env file
Just read the text and parse it, some inspiration might be used from https://github.com/Isty001/dotenv-c
Spam
Hi guys I’m looking for a c++ brush up walkthrough or anything of that sort
Ziky
Actually what does it mean to brush up / learn C++ ? - fundamental classes and inheritance? - learn features c++17? - learn even modules and other woodoo from c++ 20 - learn c++ in focus for embedded devices (no or custom dynamic allocation, constant expressions, things like newlib or custom stdlib, taming linker to put pieces on desired places in memory...) - Functional safety - like MISRA, wriitng unit testable code and measure test coverage... - Focus on libraries like Qt, STL boost...
itsmanjeet
What is the problem?
solved now, i am trying to learn about template specialization but never make them work, getting compilation error saying ::type is not a something of something i forget 😅, I somehow make it work using concept create a new concept from the specialized template and use requires keyword to enable that concept, but i don't the people post code on google are without concept ??
Lee
stop = false; // stop is given the value of 0 while (!stop) { // !stop = 1 m = (r + s) / 2.0; double y_m; y_m = a3 * pow(m, 3) + a2 * pow(m, 2) + a1 * m + a0; if (y_m == 0 || abs(s - r) < 0.000001) { t = m; cout << " The solution is " << fixed << setprecision(6) << t << ".\n"; stop = true; // stop is true indicates that stop = 1, }
Lee
stop = false; // stop is given the value of 0 while (!stop) { // !stop = 1 m = (r + s) / 2.0; double y_m; y_m = a3 * pow(m, 3) + a2 * pow(m, 2) + a1 * m + a0; if (y_m == 0 || abs(s - r) < 0.000001) { t = m; cout << " The solution is " << fixed << setprecision(6) << t << ".\n"; stop = true; // stop is true indicates that stop = 1, }
Hi I want to ask why the while loop is stopped when stop = true, as the condition in whie loop is while(!stop) where I had set stop = false, means that the loop will keep looping as the condition is stop = true because !stop = !false = true isnt it? can someone explain to me tq
Lee
!true == false —> loop stops
but I had set the stop is false, so !stop is true isnt?
Danya🔥
but I had set the stop is false, so !stop is true isnt?
> stop = true; // stop is true indicates that stop = 1,
Danya🔥
Do not write to the PM without permission
Danya🔥
When the condition is false — loop stops When you set stop = true, the condition becomes false What do you not understand exactly?
Lee
> stop = true; // stop is true indicates that stop = 1,
i set stop = false at first, then while(!stop) is equal to while(true) ?
Danya🔥
Yes
Lee
then the while loop stop looping at the end where stop = true
Lee
why it stop since it meet the condition in the while loop
Danya🔥
When you set stop = true, the condition !stop becomes false
Danya🔥
When the condition is false — loop stops
Danya🔥
Do you see the connection?
Danya🔥
Maybe you need to read some books before coding?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, I have a basic signal handling question. Both my Client and my Server only handle two signals: SIGINT and SIGPIPE using sigaction in the main process of the software. Is it right for the main process to ignore everything else? Furthermore, my server occasionally spawns threads to handle clients. Those threads don't handle signals, thought they look for their copy of errno (in the thread local storage) and if it's == EPIPE or == EINTR they do stuff. Therefore, should I specifically set the threads to ignore ALL signals?
itsmanjeet
Madhu sent a code, it has been re-uploaded as a file
Oh, that's why using ::type, and i thought we are getting some boolean value like is_same or is_convertible from enable_if too. Anyways, Thanks
Subhomoy Saha
Hello
klimi
Hello
/warn hello
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
hi guys, if I write on socket like this: while(write(socket, MEX, strlen(MEX) == -1){ // check for EPIPE error; } let's assume this is MEX: const char *MEX= "--a24h5Hf8Hk"; Sometimes the client will recieve the right thing. Other times, the client will recieve -a24h5Hf8Hk So the first "-" is missing. Can you tell me why this happens?
Exec
Hi, im still learning how to use cmake, when i run make, i got error /usr/bin/ld : cannot find -lglm : no such file ... How to fix this? I've done the google way but still the same error
Artur
Isn’t glm header only library ?
Artur
I think glm is headed only library therefore there isn’t anything to link against to
Chat Boss
Ricardo Milos ® sent a code, it has been re-uploaded as a file
Ricardo
anyone has any idea about Exception has occurred. Segmentation fault ?
Ricardo
"Exception has occurred. Segmentation fault"
Ricardo
Ye, you have problem in your code
could you show me sir ?
Ricardo
i just simply point to element i of array A[ ], and what i got is segmentation fault
Pavel
Ricardo Milos ® sent a code, it has been re-uploaded as a file
Your loop exit condition seem to be wrong, you're not exiting the inner loop and go out of array bounds
Pavel
Ricardo Milos ® sent a code, it has been re-uploaded as a file
You probably can do something like this for (int j = i; j < n && flag == 0; j++)
Anonymous
Anyone who knows how to translate integer or float to binner with function?
Ricardo
have you tried running valgrind?
no sir, still not learn about this :'), let me try
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
hi guys, so I have my client that writes on socket with a read call. If SIGPIPE kicks in, the client is ready to handle it with its own handler. The problem is that read is blocking, therefore it won't do anything until the call to write is not over. For istance, I take input with fgets, and while fgets occurs, SIGPIPE kicks in. The fgets call is blocking, therefore the client does not stop. The user tries to enter some input, presses CTRL+C and then there's the write to server. So to sum up: fgets(); »» »»» DURING FGETS THE CLIENT IS HIT BY SIGPIPE write(); the problem is that the client, after being hit by SIGPIPE, does not handle the signal with its handler, it just goes in an undefined behaviour where the write writes to the server, the server does not answer because it's off and the client is stuck. Do you know why my Client won't go in the sigpipe handler after fgets?
Jillur Rahman
How to convert decimal to binary in c?
Carlo
how can I implement cin from scratch using only unistd.h?
Moon 𓆩🤍𓆪
How to convert decimal to binary in c?
Divide by 2 and store remainders 0 or 1 like that
klimi
How to convert decimal to binary in c?
how is your decimal number stored in the memory?
𝔖𝔞𝔯𝔬
How to convert decimal to binary in c?
What do you mean by converting
𝔖𝔞𝔯𝔬
You mean like to print it ?
𝔖𝔞𝔯𝔬
Exactly how do you want bits to be rappresented
Davit
Hello Help me if you can I have the code And I want the relay to turn off after executing this code void onRelay3Change() { Serial.println("On-Change Event Relay3"); if (relay3 == 1) { digitalWrite(relay1_pin, HIGH); digitalWrite(relay4_pin, HIGH); } else { digitalWrite(relay1_pin, LOW); delay(2000); digitalWrite(relay4_pin, LOW); }
Holup
Hello there good people! How do I typecast a char array element to an int element? For example: char a[10]; a[5] = '2'; int b = (int)a[5] + 0; printf("%d", b); I wish to convert the a[5] element into an integer data type. But the code above doesn't seem to achieve that. (It doesn't print 2. But prints the ASCII value of 2. Which is 50)
Holup
maybe you can use function like atoi() , atol() etc
Without using that function there's no native way to typecast an array element and convert from one datatype to another?
Holup
Why + 0?
It's just an example code.
Saint Paul
Without using that function there's no native way to typecast an array element and convert from one datatype to another?
of curse that it's possible that's why you tried with C casting right ?? It's not simple when we are talking about integer and characters
Saint Paul
I see. Then can you please show me the path 🥺
what if you get the ASCII value of you character and then convert it in integer
Holup
But typecast still not possible?
Saint Paul
no
Holup
atoi() can't do that with char type :[ Says: no matching function to call for atoi() Edit: Figured it out. I need to pass the address to the atoi() function
An
Without using that function there's no native way to typecast an array element and convert from one datatype to another?
This is because the char variable always holds ascii value instead of its real value. To convert it properly do minus '0' like that:
An
char a = '2'; int b = a - '0';