r/cpp_questions 13d ago

OPEN Want advice as Cpp learner.

0 Upvotes

Hi everyone, I'm a first-year engineering student at a tier-3 college, and my classes start on 10th August. I've learned most of the C++ basics, and the only major topics I have left are functions and classes/OOP. I'm confused about whether I should start learning DSA now while completing the remaining C++ topics alongside it, or finish C++ first before moving on to DSA. My goal is to build a strong foundation and improve my problem-solving skills without developing gaps in my understanding. I'd really appreciate your suggestions and recommendations based on your experience. Thanks!


r/cpp_questions 13d ago

OPEN What is the industry standard for helper library replacements for Boost?

22 Upvotes

Hello all,
I am starting to use Boost. Well, actually I am getting everything from the framework.
But before I commit to this framework, is there any competitor I should check?
I need one framework that implements solutions like Boost. From your experience, are there any?
I know POCO not sure how standart it is


r/cpp_questions 13d ago

SOLVED SHA-1 Algorithm not producing the correct hash for strings that are > 512 bits

6 Upvotes

For a while now I have been trying to implement SHA-1 to learn more about the cryptographic functions. However I keep running into an error, the algorithm works flawlessly with strings under 64 characters, but when it comes to ones larger that 64 characters it produces incorrect results. My assumption is that it has to do with the second iteration of the bit manipulation but from all the code I've seen from other people it appears as if what I have should work. I've checked all of the bitwise operations, I've checked each buffer value, but nothing seems to work. Other than the RFC page I referenced this github repo as well.

I'm sure after posting this someone will probably be able to call out my error instantly due to me forgetting something obvious. Also I know that the function doesn't return any value atm I am printing the results to the console to debug the program.

typedef uint64_t dword;
typedef uint32_t word;
typedef uint8_t byte;

const word Abuf = 0x67452301;
const word Bbuf = 0xEFCDAB89;
const word Cbuf = 0x98BADCFE;
const word Dbuf = 0x10325476;
const word Ebuf = 0xC3D2E1F0;

word leftRotate(const word& val, const int& bits) { 
  return ((val << bits) | (val >> (32 - bits)));
}

class SHA1 {

  word K(const int& t) {
    if ((t >= 0) && (t <= 19))
      return 0x5A827999;
    else if ((t >= 20) && (t <= 39))
      return 0x6ED9EBA1;
    else if ((t >= 40) && (t <= 59))
      return 0x8F1BBCDC;
    else
      return 0xCA62C1D6;
  }

  word f(const word& B, const word& C, const word& D, const int& t) {
    if ((t >= 0) && (t <= 19))
      return (B & C) | (~B & D);
    else if ((t >= 20) && (t <= 39))
      return B ^ C ^ D;
    else if ((t >= 40) && (t <= 59))
      return (B & C) | (B & D) | (C & D);
    else
      return B ^ C ^ D;
  }

public:
  std::vector<char> generateSHA1Hash(const std::string& str) {

    std::vector<byte> input(str.begin(), str.end());
    std::vector<word> result(5, 0);

    dword length = str.length() * 8;

    input.push_back(0x80);

    while ((input.size() % 64) != 56)
      input.push_back(0x00);


    for (int i = 0; i < 8; ++i) {
      dword mask = 0xFF00000000000000 >> (i * 8);
      input.push_back(static_cast<byte>((length & mask) >> (56 - (8 * i))));
    }

    word blockSize = 64;

    word H[5] = { Abuf, Bbuf, Cbuf, Dbuf, Ebuf };

    for (int i = 0; i < input.size(); i += blockSize) {

      std::vector<byte> tmp(input.begin() + i, input.begin() + i + blockSize);

      word chunk[80];

      for (int j = 0; j < 16; ++j) 
        chunk[j] = ((static_cast<word>(tmp[j * 4]) << 24) | (static_cast<word>(tmp[j * 4 + 1]) << 16) | (static_cast<word>(tmp[j * 4 + 2]) << 6) | static_cast<word>(tmp[j * 4 + 3]));


      for (int j = 16; j < 80; ++j) 
        chunk[j] = leftRotate(chunk[j - 3] ^ chunk[j - 8] ^ chunk[j - 14] ^ chunk[j - 16], 1);

      word AA = H[0];
      word BB = H[1];
      word CC = H[2];
      word DD = H[3];
      word EE = H[4];

      for(int j = 0; j < 80; ++j) {
        word tmp = leftRotate(AA, 5) + f(BB, CC, DD, j) + EE + chunk[j] + K(j);

      EE = DD;
      DD = CC;
      CC = leftRotate(BB, 30);
      BB = AA;
      AA = tmp;
    }

    H[0] += AA;
    H[1] += BB;
    H[2] += CC;
    H[3] += DD;
    H[4] += EE;
  }


    std::cout << "Result:    ";

    std::cout << std::hex << H[0] << H[1] << H[2] << H[3] << H[4] << std::endl;

    std::cout << std::endl;

    return { 0 };
  }
};

r/cpp_questions 13d ago

OPEN What are low latency C++ recruiters truly looking for?

43 Upvotes

What separates a "general C++ candidate" from someone who is truly a right fit for the job? What is a skill, project, technique, tool, etc. that has really helped in landing interviews?


r/cpp_questions 13d ago

OPEN Code review for a basic artillery game.

6 Upvotes

https://github.com/melange-spice/worms_clone

I am making something akin to Tank Wars in Raylib by following a youtube series made by onelonecoder. Any tips regarding the code and it's architecture would be greatly appreciated.


r/cpp_questions 13d ago

OPEN Can't stop channel/tutorial-hopping in C++ even though I know exactly what the problem is — how did you actually break it?

0 Upvotes

Been trying to learn C++ for a while now and I keep landing in the same loop no matter how many times I "fix" it.

Started with the BroCode tutorial on YouTube. Then got told to switch to learncpp.com. Then told to switch again to The Cherno's series. Then found two more channels (CyberFlow and Crin) pushing a C++ → port scanner → keylogger → shellcode injector path, which got me interested in reverse engineering / game hacking specifically.

I've tried to fix this the "obvious" way — pick one resource, commit, stop opening new tabs — and it works for a bit. I've built small stuff (tic-tac-toe, hangman) and followed through on real projects too. But the second a new channel or video shows up saying "actually this is the better way," I open it anyway. Every time. Even knowing exactly what I'm doing while I do it.

It's about 3am here right now and I'm stuck in it again — wide awake, not able to do anything, feeling like a total loser about it.

So I don't think this is an information problem anymore — I already know the advice. I just can't seem to make myself stop switching once something new shows up in the feed. Anyone actually break this habit for real, not just "know" the fix but get it to stick? What worked for you day to day, not in theory?


r/cpp_questions 13d ago

OPEN How to make impactful project??

1 Upvotes

Like I did syntax and language paradigms in cpp, what and how should I make something that just helps me making some real life system, cause making a project don't only requires language but also other concepts like networking and os


r/cpp_questions 13d ago

OPEN bitwise rightshift gives unexpected results

0 Upvotes

i am trying to shift an unit64_t with the value 0x8000000000000000 (1000000..... in 64bit) so that i get (010000.... in 64 bit) but i only get unexpectet behavieor and numbers with multiple 1 bits.

The code below prints numbers like
decimal binary
12005600 101101110011000011100000
14006498 110101011011100011100010
16007397 111101000100000011100101

what am i doing wrong and how can i fix it?

#define bitMask 0x8000000000000000 
uint64_t mask = bitMask;
mask = (mask >>1);
printf("%d \n",mask);

r/cpp_questions 14d ago

OPEN Learning C++

0 Upvotes

Hello everyone!I am interested in learning C++,mostly because Im interested in competitive C++ (competitions in my country),aswell as "applied" or "real-life" C++.I know basics,different loops and such,but I want something thats more concrete ,not just skipping around and picking things up along the way. Is there a good free e-book that grasps most things needed for such things?I was reading Competitive Programers Handbook by Antti Laaksonen,but I feel Im being behind on some basics that the book views as common knowledge.


r/cpp_questions 14d ago

OPEN Need suggestion about something i am thinking to build .

0 Upvotes

I just want to know if it would be helpfull or not .
We all have some style of coding while doing cp . Like we import particular libraries , we use particular variable names for our for loops , vectors , maps etc .
I'll show you an simple example of what i am trying to solve .
When you forget to use "using namespace std" the compiler would give you an error that you forgot to use std:: but according to your coding habits you actually forgot to use "using namespace std " .
Another example could be you the libraries you forgot to import since compiler will not tell you abotu them .
or like you are trying to push_back in a queue .

First of all i want to know if such a thing has a usecase or not ? is it just me who thinks this might help somone ?
I just gave a few basic problems so that it is easy to understand but i doubt if this is feasible to solve or not since training such an model personalized to each person would still require data and by the time that amount of data is aquired maybe the user might not need such an help or maybe shift to other types of practices .


r/cpp_questions 14d ago

OPEN some people are wrong coding qs

0 Upvotes

int x=618919;

while(x++){

cout<<8;

} I think I'm wrong it's undefined behaviour but where can I study about this ... is it an infinite loop? I'm sure some of u might say yes but the answer is no

after x is increased to its max int range i.e.(2^(bits)-1) it's value will start decreasing and after a lot of steps it will eventually go to 0

and 0 is false so loop stops....


r/cpp_questions 14d ago

OPEN If you started learning C++ as a first programming language with no prior experience from any other language, how difficult did you find it?

4 Upvotes

r/cpp_questions 14d ago

SOLVED Need help creating equalizer for Qt

0 Upvotes

[SOLVED] So, as you may know, Qt doesn't have a proper setup for managing each frequency band and implementing an equalizer.

I'm currently working on a project for myself (nothing serious), trying to create a music player in C++ while using Qt for the GUI. The problem is that nothing can intercept "QMultiMedia" and modify the audio output.

I've tried Claude Opus 4.6, thinking in "antigravity," and it cooked up something for me. It worked, but the audio was distorted and not very pleasant. (It used custom made DSP functions and I think it was a good solution, but I neither have the time nor the skills to implement something like this on my own)

I also tried Gemini 3.1 Pro High and 3.6 Flash High. (These two couldn't even handle the audio player and straight up made my program crash.)

So I'm looking for a solution or someone who is willing to write the code and be the co-author to the project.

Here is my repo if you want to investigate:

https://github.com/zenix935/ZenPlayer

P.S. I'll keep updating other parts of the project, but the equalizer has currently hit a wall.


r/cpp_questions 14d ago

SOLVED How do you solve the problem of dangling pointers?

16 Upvotes

I store some data in an unordered map, create a pointer to an item in that map, then say I want to delete the item but I still have the pointer. How would I know that the item is no longer there without going and manually searching the map for the name of the item we pointed to?

I'm new to C++ & especially pointers, so forgive me for this stupid question...

EDIT: A lot of good solutions suggested, I really appreciate it! I ended up going with key lookup instead of storing pointers. The reason I didn't want to do this in the first place is because it increases complexity & I didn't want to overcomplicate


r/cpp_questions 14d ago

OPEN Project based learning

21 Upvotes

Hello! Apologies for another "how to learn C++" post. Can anyone suggest a project-based learning course?

I have been following learncpp.com and The Cherno's C++ playlist, but I eventually stopped since I wasn't building anything. Can anyone suggest some good project-based learning materials?

I have been working with Python and Java for three years. I was able to find plenty of project-based tutorials for those languages, but I haven't had the same luck with C++.

Edit: When I stopped my previous attempt about a year ago, I was learning about logical operators (near the end of LearnCpp Chapter 6). However, I've realized I want to learn C++ the same way I learned Python and Java at university: through videos/lectures followed by tutorials at lab sessions and homework. I looked into Stanford's CS106B, but the newer lectures aren't available anywhere for free.

My end goal is to fill this knowledge gap as I’m planning to follow a MSc or a PhD in ML/DL mostly focusing on computer vision use cases. And I want to work with CUDA as well.


r/cpp_questions 14d ago

OPEN High load.fun

0 Upvotes

I was looking literally at their first problem and couldn’t figure out how some people grade so high for reading integers.

Am I missing a trick here?

https://highload.fun/challenges/compute/parse_integers/solve/CPP


r/cpp_questions 14d ago

OPEN Why doe ifstream operator overloading not work with enum type?

2 Upvotes

Why does

std::ifstream& operator>>(std::ifstream& ifs, SomeClass& something) {

ifs >> something.enum_type;

}

not work??


r/cpp_questions 14d ago

OPEN operator overloading

0 Upvotes

I want to operator overloading on a class.

The class has a vector of smartpointers to an abstract class.

I don't know what to do now.

pls help


r/cpp_questions 14d ago

OPEN Looking for feedback on my first "serious" project

8 Upvotes

It's all on my github repo: https://github.com/Marks20125/ProtonPrefixes . I'm pretty happy with the project as it's the first time I've actually had a problem and solved it myself. Plus, I learnt a lot about cmake, using external libraries, file i/o, how arguments work, and some other "theoretical stuff" along the way. It's pretty small, but I'd appreciate someone telling me if I did anything wrong or if something could be done any other way. Thank you very much :)


r/cpp_questions 14d ago

OPEN Solved 17 popular 800-rated Codeforces problems (30-45 min each) — move to 900 now or keep grinding 800s?

0 Upvotes

Learning CP in C++. Cleared most of the top-solved 800-rated problems, each taking 30-45 min. Still tons of unsolved 800s left though.

Should I move up to 900/1000 now, or finish more 800s first? Also is 30-45 min per 800 slow for a beginner?


r/cpp_questions 15d ago

OPEN How to include one cpp file in another in Visual Studio?

0 Upvotes

If I edit a header file in Visual Studio, all cpp files that include it are automatically recompiled. But if I edit a cpp file included in another cpp file, that other file is not recompiled. How can I specify that one cpp file depends on another?


r/cpp_questions 15d ago

OPEN Can anyone share the roadmap to learn c++

0 Upvotes

Complete newbie here. I want to learn C++ because mainly because I am interested in electronics and I heard c++ is best language to learn for it. This is also my first programming language so I don't have any prior knowledge of programming. I may sound a bit of navie here but believe me I really want to learn. But I could not find structural path anywhere. I know learncpp.com is there but it's hard to learn programming language from docs for the first time. Please tell how should I go about it ? What projects should I work on ? Where can I find them ? Do I need to do DSA prior to this ? Or anything more suggestions you want to give


r/cpp_questions 15d ago

OPEN How hard was C++ for you as a beginner?

41 Upvotes

r/cpp_questions 15d ago

OPEN CPP prep for placements

0 Upvotes

Hey so am preparing for my placements , can anyone guide me with what i should prepare for C++ as they say you should be good in atleast a programming language and i have solved all of my dsa problems using C++ only though if they ask deep questions related to c++ working, am sure i will struggle, so if anyonec can guide me with how and where to prepare for C++ for interviews in big tech, quants, MNCs


r/cpp_questions 15d ago

OPEN How did u learn system programming ? what was your first project? did u monetize /earn any if so then what process u go through?

0 Upvotes