C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms (1)

1
vote
1answer
18 views

Function that assigns names to a struct using strtok

I worked around using strtok function so to assign first name and last name to a struct PERSONNE from a ...
2
votes
1answer
30 views

Student data parsing application

My application takes a .csv (comma separated values) file and serializes the data into a binary file. Then it converts the binary file back to a .csv file (identical to the original file). For ...
0
votes
1answer
26 views

Simple Blackjack/21 game in console

I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get. ...
-2
votes
0answers
21 views

How do I increase responsiveness of this code on an Arduino?

This is the code in its entirety, how could I make it so that I functions faster... It currently is on an arduino that should not be so unresponsive. Any help would be appreciated! I am using three ...
1
vote
1answer
30 views

Matching parenthesis

This is a simple implementation of a parenthesis-matcher. Given an expression, I want to find out if it is balanced.For example, the expression '{{[[()]]}}' is balanced while '{]{{}}]]' is not. I will ...
4
votes
0answers
20 views

Shortest knight path

In preparing a review of this question, I decided to rewrite the code from scratch using a more object oriented approach as I suggested in my review. To recapitulate the problem statement, we are ...
2
votes
1answer
38 views

Finding smallest number of moves

We are given a map of sides of length n and m (both n and m are less than 1000), divided into n*m fields (squares of side 1). The map looks (for example) like this: ...
8
votes
3answers
705 views

Simple calculator with classes in C++

I came to C++ from Java. This is my attempt at making a calculator on about 2 days worth of knowledge. I don't really know what is redundant or unnecessary. Nor do I know of the better ways to achieve ...
3
votes
1answer
29 views

Screen of chars

So its a class that lets you make a 'Screen' which is a n x n grid of chars. Your able to move a cursor by chosing the row and which column in the row and using that you can insert into into that ...
3
votes
1answer
29 views

“The Trip” expense-equalizing challenge [on hold]

I've solved The trip from Programming Challenges. My solution suffers from lack of floating-point precision, though. The problem: Your job is to compute, from a list of expenses, the minimum ...
5
votes
1answer
26 views

Compile-time plugin system

Background For a piece of software that I need to get extensible, I wanted to design a simple compile-time "plugin" system in C++. My use case was that the program (actually a library) can accept ...
1
vote
0answers
25 views

Persistent set (Red black tree) - follow up

Follow up of this question Things I changed: Fixed some typos Renamed variables and method to more descriptive names.(Eliminated 1 letter variables) Added static method ...
3
votes
3answers
51 views

Summation calculator of integers, squares, and cubes

Code works exactly how I want it to, but any simplification to the code that could be made would be much appreciated (granted this program uses almost everything within the scope of my C++ knowledge). ...
5
votes
2answers
73 views

Exponential search

I recently discovered the exponential search algorithm which can be used to find whether a value exists in an ordered range. An exponential search checks whether a value is smaller than the \$2^n\$th ...
-1
votes
0answers
27 views

Any defect / suggestion in my logging mechanism (c++) [on hold]

Link: https://github.com/debdipta/designpattern/tree/master/singletone In above link I have wrote one opensource logging mechanism. It is in c++ and using Singleton design pattern!!! I was thinking ...
1
vote
3answers
103 views

Process int vector and then 1) add two adjacent numbers 2) prints the sum of the first and last elements and so on

The question below came from C++ primer 5th edition. Q: Read a set of integers into a vector. Print the sum of each pair of adjacent elements. Change your program so that it prints the sum of ...
2
votes
1answer
49 views

Process string vector and change each string to uppercase

The question below came from C++ primer 5th edition. Read a sequence of words from cin and store the values a vector. After you’ve read all the words, process ...
-1
votes
1answer
97 views

Simplest linked list in C++?

My context was basically to get my linked list implementation in C++ reviewed, since I wrote it from scratch and wanted to make it as simple as possible and learn from suggestions I get. I am trying ...
2
votes
1answer
60 views

Persistent set (Red black tree)

This is a partially persistent data structure using a red black tree. It will copy \$O(lg(n))\$ items for each remove or add operation. ...
4
votes
1answer
50 views

(C++14) Handling state in C-style function pointer callbacks

I'm having some issues coming up with a sensible solution for using shared state in a C-style function pointer. I am using GLFW to handle my OpenGL context and have created a thin wrapper around all ...
4
votes
3answers
36 views

Lock-free SPMC queue

Here is my lock-free queue implementation for single producer with some preallocated memory. T is a simple type with no need for move operations. I don't use ...
1
vote
0answers
235 views

Open a window and render to it a texture

I'm new to C++ and SDL2. I made this program that makes a window. I want to make sure I'm implementing this in the most sensible way possible. I've been learning for free from online tutorials, so I ...
1
vote
1answer
45 views

minimax of input iterator range

I previously posted a question on finding the maximum value of an InputIterator range. For completeness, I thought it would be useful to post an implementation that ...
0
votes
1answer
59 views

Connect4 With AI

I have made a connect 4 console application in C++ and would love some feedback. In this project I have learned about inheritance and using virtual functions. At the moment my AI is entirely random ...
0
votes
0answers
40 views

A “generic” property: it can hold any data type

So I want a data structure that can hold any data type inside (no boost::any). Here is the (working) implementation: ...
3
votes
4answers
369 views

Min and max of numbers read from a file

I had to create this program, and I did it fine, all is working and stuff but I was wondering, what is better way of doing such thing? I want more efficient method. Problem assignment: In the ...
0
votes
3answers
78 views

Database of students

At first, I had Database to contain std::list<Student> students, but because there are over 2000 students, searching by ...
0
votes
0answers
6 views

Independent interpolations, or object linked? [closed]

I have a class that I use to render GUI elements on the screen, this class has a tree structure (with children, parent, and siblings). I created an additional class which allows me to interpolate some ...
3
votes
1answer
26 views

Terminal ESC Sequence Decoder

The goal of this code is to read-in a stream of terminal ESC sequences, and break them down and fill a vector of parameterized sequences for processing later on. For example ...
2
votes
1answer
83 views

Generating the largest decent number of given number of digits

The Sherlock and the Beast challenge from HackerRank asks to generate the following number with \$n\$ digits for \$T\$ test cases: A Decent Number has the following properties: its digits can only ...
0
votes
0answers
6 views

When writing a code for generating the largest decent number of given number of digits, where is this code failing? [duplicate]

The problem says to generate the following number with n number of digits and T test cases: A Decent Number has the following properties: Its digits can only be 3's and/or 5's. The number of 3's it ...
1
vote
2answers
55 views

Variadic average function in C++

The following code was inspired from a tutorial I found online: ...
3
votes
1answer
47 views

Generate voxel terrain with Perlin Noise

For my chunk generator for my game, it currently uses a triple nested loop, which seems very inefficient. It also seems like I could cut down a lot of code in the function somehow. Does anyone have ...
0
votes
0answers
22 views

I'm trying to make a good naming for class family [closed]

I want to extend idiom of NonCopyable class for cases where object cannot be copied or moved via copy/move constructor or assignment operators. So i divide idiom ...
4
votes
2answers
47 views

Vector Sort Function

I had heard about sorting for a while, but never actually gave it a try. So I decided to make an algorithm that would sort the members of a vector from least to greatest. Though this may seem pretty ...
1
vote
0answers
40 views

Generic implementation of mutable binary heap

std::priority_queue does not support dynamically updating element priorities. This class template extends it by allowing updating priorities of elements in the ...
1
vote
1answer
56 views

Attempt at Conway's Game of life

I tried my hands of Conway's Game of life. Well it works as I wanted it to but I want to improve my design and coding practice. I will be glad to get feedback and ideas to improve it and how to code ...
4
votes
1answer
37 views

Parallelizing an algorithm with OpenMP using a dynamic work queue

I'm looking for comments on the design, correctness and performance (not so much style) of a dynamic work queue for OpenMP worker threads. I have an algorithm that can be thought of in terms of some ...
6
votes
4answers
894 views

Random string generator

I decided to make a random string generator for fun, and it works for the most part. Since I'm an amateur at programming, I thought I would post the code to get some feedback on it, and hopefully ...
1
vote
2answers
89 views

Printing all the prime numbers between two bounds

I keep getting a time limit exceeded for this solution to SPOJ Prime1. I need to print all primes within a given interval (with intervals as large as 105, and numbers as large as 109). I've tried ...
-3
votes
0answers
55 views

C++ Interfaces and Design Principles [closed]

How does a SOLID compliant interface in C++ could be implemented? For example, is this design below SOLID compliant? I have several questions: In the Car ...
1
vote
1answer
40 views

Generic implementation of SiftUp/Down operations on binary heap

Binary heap construction and maintenance boil down to the two basic operations: sift up and sift down. Following are generic template implementations of the two operations. Any comments are welcome. ...
1
vote
0answers
69 views

HackerRank: XOR-sequence

I am trying to solve the following problem at HackerRank: XOR-Sequence An array, \$A\$, is defined as follows: \$A_0 = 0\$ \$A_x = A_{x-1} \oplus x\$ for \$x>0\$, where ...
3
votes
0answers
55 views

Game engine/C++11 software 3D renderer/WebGL library

I am a graphics programmer and was wondering about my code quality. I selected these three examples: Game engine, which uses OpenGL and has a lot of other non-graphics code A 3D software renderer, ...
1
vote
1answer
50 views

Grabs 10 bytes and converts it into a hex formatted string

I'm working on some code right now where the goal is to take in a byte stream and grab the data from the body of a message. The data is 10 bytes long and is meant to be translated into hex. ...
4
votes
2answers
62 views

LifeSaver: Hides and manipulates windows

This is a small program I wrote to hide/show different windows on my Windows PC. This is named LifeSaver because it did save my life several times, whenever someone ...
0
votes
1answer
34 views

Substring erase with certain pattern

For following input string: ...
0
votes
2answers
47 views

Box Array Sorting [on hold]

I've created a class called Box that is pretty much what it sounds like. I want to sort these box objects, and I have created a function to do so. ...
2
votes
0answers
54 views

Dynamic graph in C++11 with shortest path algorithm

I've been designing a dynamic graph to improve my understanding of C++11. The dynamic aspect means that it could represent the hyperlink structure of a chunk of the internet, with node deletion ...
0
votes
1answer
36 views

Couting numbers greater than given - using binary search

It's my first exercise involving the well-known binary search. The problem goes as follows: we are given a sequence of n numbers and we have to answer to t questions, each of which is: “How many ...