r/cpp_questions • • 18h ago

OPEN Is it still worth learning C++ 11 or should i start with C++ 17 and later?

14 Upvotes

r/cpp_questions • • 23h ago

OPEN Programmatically opening a new terminal window

1 Upvotes

I've been messing around with FTXUI, and I am wondering if it is possible for my apps to open a new terminal window and run there, instead of using the current terminal window.

An example of what I mean is what happens when opening vim. If I open vim through the terminal, it takes over the current window, like my FTXUI apps currently do. If I use the desktop shortcut, vim opens a new terminal window for itself, which closes upon closing vim. This is what I want to do.

Can anyone give me a few pointers?


r/cpp_questions • • 5h ago

OPEN Audio Mixing Libraries for C++

1 Upvotes

Hi, I'm trying to make a DJ deck as a fidget toy but I'm having trouble getting features (like reverse, speed up/down, etc.) to work on MP3 files. Wanted to ask if there were any popular audio mixing libraries I should check out to get these features + more to work on a Raspberrypi/Arduino set up. I already own a DY-HV20T and a DFPlayer if that helps at all.


r/cpp_questions • • 22h ago

OPEN Ways to grant special access to test/debug code.

1 Upvotes

In the following testing code C_string_value is a class with a protected member function kind() that supplies info about the internal implementation state. I access that via the member pointer trick. And I wonder if this is a good way to grant special access to testing code, while keeping ordinary code restricted to the public interface, and also whether you use some alternative such as (1) just make that internal functionality public, or (2) be-friend a class template Odin_, Hugin_ or Munin_, or (3) nasty formally UB preprocessor tricks, or even (4) litb's all valid C++ trick for accessing private members, or (5) something else?

#include <cppm/parameter_passing/in_.hpp>
#include <cppm/text/C_string_value.hpp>
using   cppm::in_,
        cppm::C_string_value;

#include <print>
#include <string>
using   std::print,
        std::string;

auto kind_of( in_<C_string_value> s )   // The internal kind: view of literal, or shared ptr.
{
    struct Access: C_string_value
    {
        static auto kind_of( in_<C_string_value> s ) -> int { return (s.*&Access::kind)(); }
    };

    return Access::kind_of( s );
}

auto main() -> int
{
    const auto lit = C_string_value( "Literal" );
    const auto dyn = C_string_value( +"Dynamic" );
    const auto str = C_string_value( std::string( "std::string rvalue" ) );
    const string ssl = "std::string lvalue";
    const auto str2 = C_string_value( ssl );

    print( "{} -> {}.\n", kind_of( lit ), lit.std_sv() );      // 0 -> Literal.
    print( "{} -> {}.\n", kind_of( dyn ), dyn.std_sv() );      // 1 -> Dynamic.
    print( "{} -> {}.\n", kind_of( str ), str.std_sv() );      // 1 -> std::string rvalue.
    print( "{} -> {}.\n", kind_of( str2 ), str2.std_sv() );    // 1 -> std::string lvalue.
}

EDIT (added):

I avoid conditional code on principle; to me it's so a big a no no that I didn't even include it in my list of 4 alternatives. That avoidance is about complexity, and that conditional code can change the binary layout, introduce name collisions, whatnot.

The nice thing I see about the member pointer trick, for larger scale development, is that access functions like the shown kind_of can be automatically generated in the testing/debugging code without affecting the original class.


r/cpp_questions • • 7h ago

OPEN why my program give output 8 and 3 written in cpp , I know it is wrong I trying something . I don't initialise z here but it take automatically zero and give 8 , I do chatgpt I didn't get it can you give reason ?? or logic I don't know

0 Upvotes

#include <iostream>
using namespace std;
int addDigits(int num)
{
int a, b = 0, z;

while (num != 0)
{
a = num % 10;
z = a + z;
num = num / 10;
cout << a << endl;
}

return z;
}
int main()
{
addDigits(38);
return 0;
}

output
8
3


r/cpp_questions • • 22h ago

SOLVED I don't know what's missing here

1 Upvotes

This code is not working and i don't know why (visual studio).

#include <iostream>
#include <string>

int main()
{
std::string Dividendo;
std::string Divisor;

std::string Cociente;
std::string Resto;

std::cout << "dividendo?";
std::cin >> Dividendo;
int Dividendo = Dividendo;

std::cout << "divisor?";
std::cin >> Divisor;
int Divisor = Divisor;

int Cociente = Dividendo/Divisor;
int Resto = Dividendo%Divisor;

std::cout << Cociente << " , " << Resto << std::endl;



}

What happened?


r/cpp_questions • • 23h ago

OPEN Choosing the Right Tech Stack for My First Full-Stack Project

0 Upvotes

I have learned the basics of programming and web development, and I want to build my first real-world full-stack project: an e-commerce website for a clothing brand, for which I already have a client.

I want to make it professional, from UI/UX design and database architecture to security, testing, and deployment. What tech stack would you recommend?

Finally, how important is the tech stack to recruiters? If a company uses different technologies from those I used in my project, could this put me at a disadvantage during a technical interview? What advice would you give me to make this project stand out in my portfolio and prepare for interviews?

Thank you in advance for your advice!


r/cpp_questions • • 3h ago

OPEN Is having multiple ways to implement the same thing a good feature of C++? Or is it confusing?

0 Upvotes

I'm a C++ programmer and Go developer. I started using C++ three years ago as a competitive programmer.

C++ is a programming language with so much tech debt that there are even three or more ways to initialize a variable. Its multiple programming paradigms can also be overwhelming sometimes.

I know this is for backward compatibility, and programmers can still choose how they program in C++.

But... this intentional design still feels confusing to me and looks disorganized.

I'm curious about your opinion on this.