C++ - Reddit
229 subscribers
48 photos
8 videos
1 file
25.4K links
Stay up-to-date with everything C++!
Content directly fetched from the subreddit just for you.

Join our group for discussions : @programminginc

Powered by : @r_channels
Download Telegram
Fucking windows headers. FUCK... Windows.h

I am the shmuck who gets to recompile some VC++ stuff on like an 8 - 10 month cycle - meaning, I update/recompile maybe once a year. My C++ Foo is bad and I should feel bad. The code base is barking because it wants windows.h and for the life of me I cannot find the correct current sdk or library (ms build tools 2022 era) that includes these files. Can anyone hook a brother up and point me to the correct library/installer and maybe how to install just that library from the command line?

https://redd.it/114vosj
@r_cpp
Is it defined behaviour to push an element from a vector into said vector?

I am currently implementing an alternative to std::vector. While doing so, I noticed that my alternative would lead to undefined behavior in the following std::vector equivalent scenario:

my_vector.push_back(my_vector[0]);


The problem here is that my_vector[0] returns a reference to an element that might become invalid on push_back because the vector may have to grow. Does std::vector also have this limitation or is this somehow avoided? If it is avoided - how?

https://redd.it/114zvvh
@r_cpp
any advice for c++ project

My laptop is very low spec i5 2nd gen processor 128ssd, 4gb ram but I am not interested in web development so I recently completed my c++ course on YouTube any project advice for me

https://redd.it/115f6w5
@r_cpp
question about Shared libraries and C++20 modules, their potential integration.

Shared libraries (.dll, .so, .dylib) written in C++ usually use platform/compiler -specific directives or attributes to properly export entry points and interfaces. However, given that modules are coming soon™, it could be possible to use the syntax of modules to replace compiler specific directives. This could make writing cross-platform shared libs a bit easier, besides OS-specific stuff. My question is: would it be worth it?

https://redd.it/115oj82
@r_cpp
Clang. So I got LLVM-15.0.7-win64. Type clang hello.c, and... "stdio.h" file not found. Are you kidding me? Clang doesn't come with a C99 runtime run library?!! Where should I get one?



https://redd.it/115qavk
@r_cpp
How to verify the user input is an integer with modulus?

New to C++ and I am trying to make sure the number the user enters is an integer. I looked it up and there are all these methods we haven't learned yet, but I found someone using modulus and that is something we sort of learned. Here's my code in the int main function:

int num;

cout << "Please enter a number: ";
cin >> num;
if (num % 1 == 0)
cout << "The number you entered is an integer.";
else
cout << "The number you entered is not an integer.";

And here's my output:

Please enter a number: 1.5
The number you entered is an integer.

When I purposely enter a non-integer it still says it is an integer.

&#x200B;

Any help is appreciated, thanks.

https://redd.it/115sh6g
@r_cpp
simple console calculator app not working

I have no idea why this isn't working so please let me know if you can identify a problem:

\#include <iostream>
\#include <cmath>
int main(){
char op;
double num1;
double num2;
double result;
std::cout << "***********CALCULATOR*************";
std::cout << "Enter either (+ - * /): " << '\\n';
std::cin >> op;
std::cout << "What is your first number: "<< '\\n';
std::cin << num1;
std::cout << "What is your second number: " << '\\n';
std::cin >> num2;
switch(op){
case '+':
            result = num1 + num2;
std::cout << "Result: " << result;
break;
case '-':
            result = num1 - num2;
std::cout << "Result: " << result;
break;
case '*':
            result = num1 * num2;
std::cout << "Result: " << result;
break;
case '/':
            result = num1 / num2;
std::cout << "Result: " << result;
break;
default:
std::cout << "You didn't enter the operator correctly";
break;


    }
std::cout << "**********************************";


return 0;
}

https://redd.it/115vcpg
@r_cpp
Breaking Enigma with the Power of Modern C++ - Mathieu Ropert - Meeting C++ 2022
https://www.youtube.com/watch?v=zXZ4RAWTJ8g

https://redd.it/115wg6a
@r_cpp
vector<int> - how do you remove all unique values leaving only the elements with duplicates?

Example 1: {2,2,5,5,5,1,1} I want this to be {2,2,5,5,5,1,1}

\- No element has been removed since all of them have a duplicate value.

Example 2: {2,2,5,5,5,1,3} I want this to be {2,2,5,5,5}

\- 1 and 3 have been removed since these two integers have no duplicates.

&#x200B;

is there a function for a vector that does this? I only know how to remove all duplicates element.

theVector.erase( unique( theVector.begin(), theVector.end() ), theVector.end() );

https://redd.it/115xn2r
@r_cpp
bigint literal

I coded a [bigint (user-defined) literal](https://github.com/jrmwng/bigint_literal) this weekend. I would like to listen to your comments.

#include "bigint_literal.h"

__int128 nExample128 = -0x80000000000000000000000000000000_bigint;
long long nExample64 = -0x8000000000000000_bigint;
int nExample32 = -0x80000000_bigint;
short nExample16 = -0x8000_bigint;

https://redd.it/11631dv
@r_cpp
Why C++ has static dtors ?

Hi,

I'm curious about why C++ language has static dtors ? I mean at the end of the program any memory and file handles are already released by OS.

I feel like it is something to do with shared libraries but I'm not certain.

https://redd.it/1166ifu
@r_cpp
DLL Linking

Can someone please provide links to good articles for DLL Linking in the c++ project?
I don't want to reduce workload on while calling the DLL's API
Also is it mandatory to link with .lib while loading DLL??

https://redd.it/116aaxz
@r_cpp
Software Architecture With C++ by Adrian Ostrowski, Piotr Gaczkowski: review/thoughts

I am looking to get a better understanding of good software architecture in c++ and want to see if anyone has used this book and would share their experiences.

I want to be able to have a good understanding for software architecture primary in c++ based solutions and do see some interesting topics/characters in this book that I think could help me with my current jobset but what like to see if anyone has any experience with it.

Any other recommendations would be helpful as - thanks :)

https://redd.it/116i1d8
@r_cpp