General C++ Programming - October 2023

Not sure if I got this right
 
Hi, Here is my assignment question: C++ Program Write a program that adds the positive odd numbers you enter from the keyboard while ignoring the even n...
[17 replies] Last: Oh, something to remember. You know what the code is supposed to do... (by George P)
question about hand-over-hand fine-grained locking mechanism
 
hello everyone...probably this is my first post here so CMIIW...btw currently I have a problem regarding locking implementation on sorted singly-linked list. So...
[12 replies] Last: node<T>* succ = first; std::unique_lock<std::mutex> current... (by seeplus)
Stuck again and need help
 
I cannot get the code button to work. HI, This is my assignment. <You are writing a program that will display names (first and last) in a column. The max...
[9 replies] Last: So I think that I need setw(30) With cout, setw() affects what come... (by seeplus)
I'm stuck with an odd error message
 
Here is my code there is not much to it. I am supposed to write some code to go from 1 to 10 and each time I add 3 to the total. I start at 7. #include <iost...
[8 replies] Last: The code as originally posted only while looped on total = seven + 3;... (by George P)
Lock
 
I have an issue which for simplicity comes down to this: void process(int n) { // Do processing of n if not already processing same value of n /...
[6 replies] Last: If you want to stay cross-platform and still support Win32, have a loo... (by kigar64551)
by Cplusc
Unix transcript of build event
 
I've successfully developed a C++ code using Visual Studio on Windows, and my current task involves transitioning it to a Unix-based supercluster. The complicat...
[9 replies] Last: POSIX API (i.e. <unistd.h>), which I wouldn't call "non-standard" I... (by seeplus)
I'm in school and stuck trying to go from a double to an integer
 
Hi All, I am taking a course in c++ and doing an assignment. I have to post the whole code I have right now. Here is the code I am trying to go from a dou...
[7 replies] Last: @mathman54. Please don't post line numbers as part of the code. It mak... (by seeplus)
Format woes
 
int main() { std::cout << std::format("{:< 8f}", .111111); } displays 0.111111 but I need .111111 (no initial 0). Is this possible just using forma...
[9 replies] Last: std::cout << s.substr(*s.c_str() == '0'); (by mbozzi)
adding chrono::months to a sys_days
 
Trying to add 1 month to today does not yield a sys_days!!! chrono::sys_days today = getToday(); auto next_month = today + chrono::months{ 1 }; nex...
[4 replies] Last: Trying to add 1 month to today does not yield a sys_days!!! Well my... (by seeplus)
by helios
Apparently this is valid
 
I just noticed I had this somewhere without realizing. void foo(); void bar(){ return foo(); } I guess I can see there are cases where it could...
[1 reply] : Definitely just *looks* like an unintentional bug from a programmer, a... (by Ganado)
by Cplusc
Line box intersection
 
I am casting a line from any arbitrary point in a 3D space and I want to check if the line intersect with the box or not. I found the code for this here https:/...
[1 reply] : Now is a great time to do some debugging, with a debugger :+) Actuall... (by TheIdeasMan)
Calling C++ method pointers
 
I'm having a problem trying to a C++ method pointer. There' lots of examples on the net of using simple C function pointers, but working examples of passing...
[1 reply] : Line 53 should be: if (! (this->*fp)(str)) // Do the... (by mbozzi)
literal for one day
 
Hi, I have: time_point<system_clock> tp; tp += days{ 1 } + 23h + 55min; // days{1} + hours{23} + minutes{55}; I tried to use the literal for ...
[5 replies] Last: @George P day (of month) exists but day s (duration) does not exist ... (by coder777)
by Cplusc
MPI Data Type
 
I am trying to broadcast a used-defined data(boundingbox) but unfortunately, the data differ in different processors. here is the code: void Geometry::gener...
[2 replies] Last: Thanks, you are right. (by Cplusc)
64 bit architecture and programming
 
Hi guys, So I'm not sure if this belongs in the longue, but it does pertain to programming and potentially to C++(maybe depending on the compiler?) I'm curren...
[14 replies] Last: Right, well in that case an example of working with the branch predi... (by Ganado)
by Runsva
Call Function in DLL from C++ Program?
 
I'm attempting to call a function inside a shared library DLL file using a C++ program. I'm using C++ 17 for all files in question. The DLL file in question ...
[13 replies] Last: The difference between _cdecl and _stdcall is going to determine which... (by seeplus)
by Runsva
Include Mutex when building with G++ via Command Prompt?
 
I want to compile a C++ program that includes & uses the mutex library, with G++ via the Command Prompt on a Windows system. I'm attempting to compile with C++ ...
[3 replies] Last: Looking to compile on a Windows system there are several newer options... (by George P)
When to choose Args&& instead of Args?
 
Hi, I have a simple question. When do we choose this implementation: template<class... Args> internal::multi_order_by_t<Args...> multi_order_by(Args&&...
[2 replies] Last: You use std::forward with && for perfect forwarding. As the type of Ar... (by seeplus)
how to send output to console when using catch2 for C++
 
Hi, I have a console project that links with catch2 libraries but I can't see the output in the console!! How can I see it ? Regards, Juan Dent
[no replies]
by Runsva
Build Shared Library File from String of Code?
 
Suppose I have a C++ code excerpt literal saved in a std::string variable, as such: #include <iostream> int main() { std::string code = ""; code +...
[2 replies] Last: You can not just "save" the C/C++ code to a DLL file. That is becaus... (by kigar64551)
  Archived months: [sep2023] [nov2023]

This is an archived page. To post a new message, go to the current page.