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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

In computer science, a pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

0
votes
0answers
14 views

Remove extra spaces from a string - C programming [on hold]

The task is to remove all the extra spaces in the string, just to leave one space between every word, for example if the input string is volim OR ...
6
votes
4answers
306 views

Add Two Numbers given in Reverse Order from a Linked List

Problem Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add ...
1
vote
1answer
28 views

Generic Single Linked List with smart pointers follow up part 3

Okay, this will most likely be the last post I make for Singe Linked List unless significant revision is needed. This post following from here. Shout out to @hoffmale for showing me the ways of the ...
1
vote
2answers
61 views

Generic Single Linked List with smart pointers follow up part 2

This is probably the last time I will post this data structure that I have been working on. I have added in an iterator and const_iterator class (although I do not use them probably where I should be)....
1
vote
2answers
56 views

Generic Vector Class using smart_pointers

I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to see ...
2
votes
4answers
122 views

Generic Single Linked List Using Smart Pointers Follow up

I am extending this post following from here. I made some of the changes that I could make in the previous post. Although, I have not been successful in creating iterators for my class. The reason ...
7
votes
4answers
766 views

custom smart pointer class template

Kindly provide your review comments: ...
4
votes
2answers
174 views

Doubly linked list std::unique_ptr template class implementation

Inspired by the talk of Herb Sutter in CppCon2016, I decided to make a doubly linked list using templates, smart pointers, and raw pointers (for back-pointers, having a cycle of ...
3
votes
2answers
82 views

A traits class for (compound) pointers - beyond what std::pointer_traits offers

This is a percolation of ideas which originated this SO question: Compound pointer traits class with method generalizing make_shared and make_unique? The ...
1
vote
2answers
64 views

K&R Exercise 5-15: sorting with extra options

As I'm learning to program in C, I'm making my way through K&R. The goal of the exercise is to add a option to the program so that the sorting does not depend on upper or lower-case letters. ...
10
votes
1answer
142 views

Consuming a picnic lunch

I have a number of related classes (Burger, Pizza, Cupcake) with a common base class ...
5
votes
1answer
284 views

Graceful thread shutdown with std::move [closed]

I have a thread as part of a class that access the class's data members. The class has a move constructor that moves some of the old class's data members into the new object being constructed. Before ...
3
votes
1answer
81 views

Simple packet parsing command pattern

I'm currently creating a small server back-end. My goal is to write an (efficient) packet parser in C++17 using the command pattern. The packets are given by: ...
11
votes
3answers
132 views

A moveable QScopedPointer, or a Qt and std cross-compatible unique_pointer

I'm a hobby programmer, so I've never been through a code review before (online or offline). That said, here goes: Background I use Qt extensively but have long wanted ...
1
vote
1answer
91 views

Single Linked List - simple approach

I am a student, trying to learn C++11 and data structures. I would like to ask you to to review my code. I have spent some time and analyse similar questions on Code Review and it gave me basic idea ...
3
votes
3answers
62 views

Swapping int with string using getchar() and putchar()

I wrote code that replaces integers from 0 to 3 with strings. I was only allowed to use getchar() and putchar(). If the input is ...
3
votes
1answer
110 views

Strategy design pattern in C++ using unique_ptr

1. Introduction This is for my ANN project. Each building block of ANN, neuron, has activation function which determines how to get the output given the input (see formula in on repo I linked). I ...
-3
votes
1answer
97 views

Parser function returning a pointer

Two of my colleagues suggested that I not use a C function to return a char pointer. The way to get a char pointer is to pass it to a function and let the function ...
3
votes
2answers
82 views

Copy-and-Move Concept Using Smart Pointer

I tried to implement a simple container class using the copy-and-move idiom. I am learning the changes to C++ as of C++11 and later. Is the code exception safe? I chose to use a smart pointer. Is <...
2
votes
2answers
173 views

Swap Nodes in Pairs in singly linked list

Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only ...
2
votes
1answer
123 views

QT - Class For Connecting to Mqtt Broker With QMqttClient

Task: Class for connecting to a mqtt broker using QMqttClient and getting notified on connect and ...
11
votes
2answers
950 views

Trie Data Structure Implementation in C++11 using Smart Pointers — follow-up

Link to my first question. I followed @JDługosz recommendations. How does it look? Do you have any further recommendations? Is it better (if possible) to replace shared_ptr with unique_ptr? How could ...
5
votes
2answers
115 views

Smart pointer that cannot be nullptr

Sometimes I need a reference counting smart pointer that should not be nullptr. For example, I want to share a very heavy object without copying. And it's more convenient to place it on the heap. So I ...
9
votes
4answers
2k views

Singly Linked List implementation C++

Linked List C++ I am new to data structures and I have to implement my own data structures for a project. I have made this working Singly Linked List data structure in C++. I would like to ask ...
1
vote
1answer
184 views

Graph Representation using smart pointers. Kosaraju's algorithm implementation

Coming from a Java background, and being fairly new to C++ as well as code review, I am trying to get accustomed to C++11/14 concepts. I have been reading Modern Effective C++ by Scott Meyers to ...
2
votes
1answer
136 views

Multi-purpose generic pointer array with optional type-checking

I've been using this data structure in my projects for a while and finally decided to clean it up a bit and publish it online, but first I'm posting it here for code review. (EDIT: It has now been ...
1
vote
1answer
72 views

Class Putting Self in std::vector

This is a small test to try and add a copy of a containing class into a vector. To me, it looks very ugly. I hate the fact I need to write a constructor based off of a pointer in order to add the ...
4
votes
3answers
269 views

Doubly Linked List Implementation [C++]

C++ noob reporting. I'm working on implementing a doubly linked list using two separate classes: one class, called node, containing your standard doubly linked list ...
4
votes
1answer
140 views

Wrapping an IntPtr in a Struct for safer Interop

Consider the following C#/C interop scenario: ...
6
votes
2answers
134 views

RAII-style single-linked list

After watching Herb Sutter describe single-linked lists in terms of unique_ptr I decided to implement my own. In particular I want to know if my move semantics are ...
2
votes
1answer
55 views

C Vigenere Encryptor

This code is tested and working properly, I'm looking for some feedback on the following functions. Pretty straight forward and simple, but if additional information is desired, ask and I will gladly ...
6
votes
2answers
439 views

Finding first recurring letter in each string of a given set

First input is the number of strings ex: 5 Second input is a set of strings ex: hello world how are you Output the letter in the string ex: 'l' in string 1 Below is my code: ...
5
votes
3answers
159 views

Custom thread-safe shared/weak pointer implementation in C++98

So I am pretty sure the CppCoreGuidelines say that you should disregard standard libraries and write your own. Not sure I remember where, probably P.13 or somewhere around there... Anyway here is my ...
1
vote
1answer
104 views

Returning containers from function - C++ [closed]

I've been trying to implement a few interfaces for processing data. And most of the time I do new of container and return a smart pointer to this container. ...
9
votes
4answers
1k views

Populating a structure

I'm solving K&R exercise 1-13: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation ...
1
vote
0answers
124 views

C++11 CLH Lock Implementation

As a hobbyist programmer I have been reading "The Art of Multiprocessor Programming" (Herlihy, Maurice; Shavit, Nir) and converting the Java spin locks into C++ - I have enjoyed this and learned a lot....
2
votes
1answer
117 views

Wrapping the iOS triple buffering procedure in a generic swift class

In the Metal sample code and best practices guides it is advised to use a triple buffering technique to avoid access conflicts between the cpu and the gpu. The required code to do so requires ...
8
votes
2answers
3k views

Traversing an array with a pointer to the array

I was thinking about how to traverse an array without an int iterator, and I'm curious if my answer is good/bad. The first for loop simply populates each element ...
3
votes
1answer
161 views

Parsing an XML file into a linked list

I am using libxml library to parse the xml file into my code and then assign each element node to the corresponding linked list node. I think the code runs just ...
4
votes
2answers
1k views

Binary Tree in C

It takes integers from argv[] and inserts into tree, making sure to allocate memory and free that memory once the program has finished. How can I improve code quality, what are your suggestions? <...
3
votes
2answers
93 views

Find string length using pointers

I'm trying to write a function that will work out the length of two string char arrays, using pointer arithmetic. It seems to be working but I'm still getting used to pointers and addresses etc and ...
3
votes
1answer
261 views

Templated Game Resource Manager

After scanning some of the questions here about resource managers I've made some changes, and while it is much improved I still feel it's not quite up to snuff. It tried to make it work for all data ...
2
votes
1answer
90 views

A binary search implementation for any datatype in C (continuation)

This is an indirect follow-up to this post. I've tried to assimilate all that was instructed and here's my attempt at binary search. binary_search.h ...
7
votes
5answers
1k views

My linked list implementation in C

I have been reading about pointers in C and I thought implementing a linked list would be a good exercise to test my knowledge. Below is my code and it is 100% functional. All I am looking for is ...
3
votes
2answers
723 views

C++11 Singly Linked List with raw pointers

Regarding C++, I have an experience in writing only short non-object-oriented programs and competitive programming challenges. I would like to get your feedback about my C++ style, design decisions, ...
2
votes
2answers
71 views

A linear search implementation for any data type in C

I performed an "experiment" to test my understanding of pointers in C. I decided to write a linear search function that can work on any array provided there is an existing function to compare the ...
3
votes
2answers
130 views

Delete node from linked list, using offsetof to set the tail pointer

This is a follow on from this question - Delete node from singly linked list with tail pointer in C I've attempted to implement node deletion using the offsetof() ...
1
vote
1answer
293 views

Delete node from singly linked list with tail pointer in C

I'm trying to implement a single linked list based on Linus' comments about double pointers. In my case I'm also using a tail pointer and I'm wondering if there's a better way to update the tail ...
5
votes
1answer
130 views

Implementation of an intrusive SmartPointer

Here is my implementation of SmartPointer. It is intrusive and tiny. How can I improve it? For example, constexpr, ...
1
vote
1answer
115 views

Using mutable keyword to implement an owner-pointer class (C++03)

For a couple of days, I have been trying to implement an own templated class called owner_ptr (for my little project) whose instances has ownership over a ...