Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++...

0
votes
0answers
17 views

Correctness of iterative DFS for cycle detection

I'm attempting the Graph Algorithms section in CLRS right now. Here's an iterative DFS using a stack called nodes. ...
2
votes
1answer
52 views

Doubly linked list using C++ and templates

Working doubly linked list using C++ and templates, I tried to make it by myself. I tried to use head and tail as buffers and make a simple implementation. Please help me understand what I have done ...
0
votes
0answers
7 views

Optimal way to use GLFW callbacks inside classes [on hold]

Im creating a window class in C++ to provide a bit of abstraction for a GLFW window. To me it makes sense to add a key_callback as a method in my class. The issue is ofcourse that GLFW is written in C,...
2
votes
1answer
41 views

Very basic C++ HTTP Parser

I was bored, so I decided to write a very basic HTTP Request/Response parser in C++. Some Notes: This isn't meant to be a complete implementation of the HTTP protocol This isn't meant to be the ...
2
votes
1answer
44 views

C++ class for a flag register in a Chip8 emulator

In order to learn C++ I decided to code a Chip8 emulator following a tutorial. When I came across the idea of a flag register and decided it would be fun to implement in order to get familiar with ...
-3
votes
0answers
23 views

WA in “Spread the Word” [on hold]

Problem Link https://www.codechef.com/SNCKQL19/problems/SPREAD2/ Link to the solution https://ideone.com/JAO5lX I am ...
0
votes
0answers
13 views

Inserting nodes to the end of a linked list by function [on hold]

I am trying to insert nodes to the end of a linked list by function. This is the insertNode function: ...
2
votes
2answers
57 views

N-puzzle solver using A* with Manhattan + Linear Conflict

I've been working on this solution for a couple days now. Finally managed to get it to work and I got it to where it solves about half of the time. The other half goes for so long that it eventually ...
2
votes
2answers
454 views

Processing voice samples

I'm within an audio application that sends variable-length buffers to my DLL, which will process at higher speed (48000 samples per sec, but can also be higher). Here's the code I've written: ...
-4
votes
0answers
15 views

Given two integers x and y, the following recursive definition determines the greatest common divisor (gcd) of x and y, gcd(x, y): [on hold]

question : { x if y = 0 gcd(x, y) = { gcd(y, x % y) if y ≠ 0 Write the program to test this fuction. What is the value of: a. gcd(54, ...
3
votes
2answers
63 views

Testing Video Frames for Uniqueness

I'm working on a program that will (hopefully) eventually allow me to perform frame rate analysis like Digital Foundry does. The code below works (as far as I know), but before I iterate on it, I'd ...
3
votes
3answers
65 views

Generate sinusoid as Wave file

This is a little program to show how a WAVe-File Generator could be written. It use a Function-Object "SinFunction" to calculate the value of any point of the amplitude in time. This object and two ...
4
votes
0answers
54 views
+50

Speeding up Buddhabrot calculation in PyCuda

I've just started using PyCuda with Python 3, but I have some experience in high performance computing on CPU. I've tried to port one of my old models for generating the Buddhabrot to run on my GPU ...
2
votes
0answers
30 views

SDL2/C++ Blackjack Game

I recently just finished making this blackjack game using C++ and SDL2. Although this took a lot longer than I expected it to, I feel like I'm getting a good hang of everything. However, this is only ...
-1
votes
0answers
16 views

Can anybody help me to construct a Wave Function Generator [on hold]

I'm trying to write a little Wave Function Generator but I have anything not right understand. So I became the Error that "Data" Chunk is not written. // basic file operations ...
-1
votes
0answers
26 views

Linked list in the linked list c++ [on hold]

Example:: Receipt1: Name:Customer 1 Order::: Index:1(Name:Frame0001, Quantity:1)+ Index:1(Name:Frame0001, Quantity:2) Receipt2: Name:Customer 2 Order::: Index:1(Name:Frame0001, Quantity:15) Problem ...
10
votes
1answer
567 views

C++ math vector template

I wrote a basic template for a vector of arbitrary dimension to be used in a 3D-engine. Most operators make use of C++ template meta programming and instances are implicitly convertible to glm types. ...
0
votes
2answers
384 views

“Spread the Word” CodeChef challenge

I am solving the "Spread the Word" problem on CodeChef: Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest. There are \$N\$ people numbered 1 ...
1
vote
0answers
52 views

C++ embedded application to control a light with a timer

I enhanced the my daughter's bed light to IoT. Specifically I can turn the light on/off remotely and there is a timer & alarm function. All of this is implemented with a Particle Photon. This ...
0
votes
2answers
39 views

C++ - Hash map implementation using smart pointers

I am trying a simple Hash Map implementation in c++. I have used this and this as reference. The implemented design uses a class HashEntry to manage individual key-...
-3
votes
0answers
11 views

how to code numbers in c++ [on hold]

how can you make 3 the maximum integer instead of 10 in c++. example, a number '111' instead of the last integer going all the way from 1 to 9 so that it can become '121' it goes from 1 to 3 so that ...
-5
votes
0answers
27 views

C++ Code analysis Tool [on hold]

I would like to review a C++ code. My host machine is Ubuntu 18.04. Which is the best software which help to review the code, reocrd the comments and enable to share it, which may be viewed in some ...
2
votes
1answer
33 views

C++ - Astar search algorithm using user defined class

The objective of the post is to improve design and improve command on C++. Given a map, start point and end point, the shortest path to end point from the start point has to be found out using Astar (...
1
vote
1answer
80 views

A Simple C++ Client That Sends Data Over TLS Using OpenSSL

I am learning C++ and socket programming and OpenSSL. As such, I decided to make a simple client that opens a TLS connection and writes some data as practice. It also serves as a base for more complex ...
0
votes
0answers
39 views

Static bounds tensor

Basic tensor class with static bounds. I want to get this done properly, because plan on using this on the GPU in the future. This also means I cant use any STL containers. Speed is pretty important. ...
1
vote
1answer
57 views

C++ heap CPS: Continuation Passing Style with Recursion

I am willing to see how to write readable and efficient continuations on the heap in c++. I am not quite satisfied. The following is just an exercise: it is coded for fun. I post the code here ...
5
votes
1answer
74 views

Single producer single consumer wait-free object container

I have a fast producer thread and a slow consumer thread. The consumer processes as many objects as it can and simply ignores the rest in order to not slow down the producer. Therefore, I used a one-...
0
votes
0answers
33 views

C++ code to support I/O and arithmetic on fractions [closed]

Basically, this is the description Consider the following class definition: ...
2
votes
1answer
62 views

Password encrypting tool

I wrote a tool that takes a domain name and a password, concatenates them, hashes the result with sha512, and returns the result encoded in base64 truncated to 32 characters. The main idea behind this ...
1
vote
0answers
17 views

JSON Test Harness: Part 4

Part 1: JSON Test Harness: Part 1 Part 2: JSON Test Harness: Part 2 Part 3: JSON Test Harness: Part 3 Time to review some test harness code I have written. https://github.com/Loki-Astari/...
1
vote
0answers
12 views

JSON Test Harness: Part 3

Part 1: JSON Test Harness: Part 1 Part 2: JSON Test Harness: Part 2 Part 4: JSON Test Harness: Part 4 Time to review some test harness code I have written. https://github.com/Loki-Astari/...
1
vote
0answers
15 views

JSON Test Harness: Part 2

Part 1: JSON Test Harness: Part 1 Part 3: JSON Test Harness: Part 3 Part 4: JSON Test Harness: Part 4 Time to review some test harness code I have written. https://github.com/Loki-Astari/...
2
votes
0answers
29 views

JSON Test Harness: Part 1

Part 2: JSON Test Harness: Part 2 Part 3: JSON Test Harness: Part 3 Part 4: JSON Test Harness: Part 4 Time to review some test harness code I have written. https://github.com/Loki-Astari/...
1
vote
1answer
62 views

Tic tac toe game using C++

I wrote this C++ code for Tic-tac-toe for an interview (The basic skeleton was pre-provided) and got rejected because the code was too complex and inefficient. I'm not an expert programmer so I'd like ...
-2
votes
0answers
35 views

return value optimization with std::pair [closed]

I am currently quite puzzled with C++17`s guaranteed RVO and its implications. I understand that for NRVO to kick in, I need to make sure that to return one and the same instance of an object ...
1
vote
1answer
51 views

C++ Breakout game using SDL

I did a big mistake to create procedural C++ breakout game on start and now im having trouble converting it into OOP. As far as I can see I need classes: Loptica (eng. Ball), Splav (eng. Paddle), ...
9
votes
4answers
1k views

Program that finds the longest word not containing one of the disallowed characters

Problem definition Find the longest word that doesn't contain any of the following characters: gkmqvwxz Input comes from a file named ...
0
votes
0answers
12 views

Iterative DFS for computing vulnerabilities in a connected Undirected Graph

So I'm been attempting CLRS's Graph Algorithms section lately. There are a few questions on Articulation Points and Bridges in a connected Undirected Graph, even ...
-2
votes
1answer
42 views

Remove key-value pairs from string when only key is given

I have a need to parse strings that contain pairs of key : value, and remove a specific pair, when I'm only given the key. Example: Given the string ...
23
votes
6answers
4k views

Create a C style char** from a C++ vector<string>

I am dealing with some older C style APIs, like Posix execve that take a char**. In the rest of my code, I prefer to use a ...
1
vote
2answers
72 views

Graph library including minimum spanning tree using Kruskal's Algorithm

I've only ever made small programs. So, I've tried to make something large but easily reusable/extendable. Posted below are the beginnings of a graph library I've written up. One particular point I'd ...
-1
votes
0answers
22 views

Output of a program [closed]

I have a preliminary doubt regarding this code. #include <stdio.h> int main() { char *ptr = "GeeksQuiz"; printf("%c", *&*&ptr); return 0; } Why ...
5
votes
3answers
949 views

C++ code to sort a list of elements

This is a code uses mergesort algorithm to sort a list of elements.What are the possible improvements on the code?Also are there any unhealthy coding practice involved in this code? ...
2
votes
2answers
46 views

Finite State Machine in C++

I made a state machine. You can press 0 and 1 to switch between the hypothetical menu and playing state. I hope you can help me improve it further. StateManager.h ...
-3
votes
0answers
35 views

making a “terminal” in visual studio [closed]

I'm new to c++ programming and I am trying to make a basic "text-based RPG". I wanted to make this so I could show my teacher (sophomore in high school). I'm pretty confident in my ability to code the ...
7
votes
2answers
224 views

Factory for constructing directed graphs in C++

I want to implement a directed graph which has 3 main kind of edges: self referencing edges non directional edges between two nodes directional edges between two nodes Also I want to be able to do ...
0
votes
0answers
28 views

Iterative DFS for computing timestamps for all nodes in a Directed Graph

I'm attempting the Graph Algorithms section in CLRS right now. Here's an iterative DFS using a stack called nodes. ...
-5
votes
1answer
50 views

How to remove this simple code repetition? [closed]

I have written these three methods in a class like this: ...
1
vote
0answers
44 views

Using HashMaps to track parent and rank of graph nodes

I often find myself in the following position: I have created a class in some file, and would like to add a new data member to that class without changing the original class definition. Now, you ...
2
votes
0answers
55 views

C++ Generic Action Dispatching & Handling System

I am trying to achieve an event system, which I refer as actions, and would like your ideas about what I come up with so far. I have made research on several design patterns, and several systems used ...