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.

learn more… | top users | synonyms (1)

0
votes
1answer
39 views

Shell command line program

I have refactored a for loop into a function. I'm still a beginner at using C utility functions such as strtok, ...
4
votes
1answer
78 views

Avoiding pointers in this C++ linked list

As I know it is not good idea to have so many pointers in c++ code. But I have written this simple implementation of linked list in c++ and there are many pointers in it, how can I improve that? Also ...
1
vote
1answer
61 views

Operator Oveloading: “+” and “==” for two classes

I have one class Number (base class) and two child class Fraction and ...
6
votes
3answers
116 views

View programming pattern in C++ without raw pointers

I'm trying to achieve, for lack of a better term, a "view" pattern in C++. It's probably most comparable to "views" in the Database world, where one can make a query, and then perhaps aggregate the ...
-1
votes
1answer
52 views

&(array[index]) vs (array + index) [closed]

So I'm working with a function that returns a pointer to a list item. Right now, I'm using: ...
4
votes
2answers
71 views

Generate all permutations in C

I have written code for generating all the permutations in C as explained here. How can the code be optimized? Are there any memory leaks? ...
4
votes
1answer
84 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 ...
2
votes
0answers
38 views

Transform and transpose byte[] of 32bit image data in 24bit array image data

I would like to know if someone can think about a better solution for doing this stuff. I have an array of raw bitmap data in 32bit format (RGBA). I need to transform and transpose this array into a ...
2
votes
2answers
172 views

ShoppingCart and Item Classes

I've built a class for an e-commerce Item, and the ShoppingCart class for checkout functions. The thing I'm most concerned ...
3
votes
1answer
120 views

Overloading operator ->* for smart pointers

I am implementing a smart pointer class template and I want to overload operator ->* (even if it’s rarely done). I came across Scott Meyer’s article Implementing ...
5
votes
2answers
78 views

Remove duplicates from unsorted linked list

Remove duplicate elements from linked list. ...
1
vote
2answers
72 views

Read characters from stdin into an resizeable array

As first steps in C, I'm trying to write a program that reads from stdin into an array allocated on the free store, until an exclamation mark ! is entered. The ...
3
votes
1answer
24 views

Given a string, print another one without a given char

My aim is to write a C program (I must create a function) that, given a string and a character, returns another string without the given char value. For example: ...
6
votes
2answers
127 views

Fixed-Size Memory Pool

I've been reading about Memory Pools since I came across them in the book Game Programming Complete 4th Edition, and I decided to try and spin my own since I didn't quite understand how the one they ...
4
votes
2answers
191 views

Memory management for Red-Black Tree

I've written this program yesterday, and I was reminded why I dreaded C++ before turning to Java: pointers and associated terms (like destructors, initializations and copy/move constructors) are ...
2
votes
1answer
132 views

Efficient C++ Resource Manager

This is my final attempt of making an efficient ResourceManager class, which takes care of allocating OpenGL objects (like Shader, Textures, Meshes, ...). It stores ...
-3
votes
2answers
75 views

Array to function to int arithmetic

I want to get the value of an integer from within a struct pointer. Simply: int cool = *(*(&(coolPtr->map)) + x); can this be simplified? The rest of the ...
1
vote
2answers
226 views

C++ Winsock HTTP Request Library

I'm trying to write a HTTP Request library for practice with Sockets and C++ in general. I created a seperate function to setup the struct needed to Connect() however it is now breaking and I cant ...
2
votes
3answers
482 views

DeepPtr: a deep-copying unique_ptr wrapper in C++

When using the pimple idiom it is necessary to represent your "impl" as a forward declared pointer in the header file. This necessitates a lot of boilerplate code to implement the rule of five. ...
6
votes
1answer
151 views

Random String Generation - Base36 and optimization

This is some fairly heavily optimized C#. Aside from reading like C++ code due to all of the pointers, does this pass sanity checks, and is there any way to improve it, while keeping its speed (or ...
7
votes
1answer
136 views

Cancellable futures, interaction with throwing destructors

I'm reinventing std::future from scratch (for an upcoming talk). I'd like to incorporate as many of the latest and most likely-to-succeed proposals as possible, and ...
4
votes
1answer
120 views
0
votes
1answer
126 views

Refactor C# unsafe method [closed]

I have the following two unsafe methods that I would like to refactor: ...
4
votes
1answer
93 views

Passing variable pointer as string to another function

With Delphi 7 I need to create a TStream variable and use/free it in another part of the code. Unfortunately it cannot be passed as "normal" parameter. I created a ...
8
votes
3answers
344 views

Generic stack in C

I tried to implement a generic stack in C using void pointers and tried to keep it as simple as possible by delegating all responsibility to the caller of the ...
5
votes
2answers
104 views

Splitting string by words to new strings

Function: ...
19
votes
5answers
1k views

Inventorizing the universe

I recently started re-factoring a project I hadn't touched in many months. The original purpose was to be an inventory management system for a game I played, Ogame. In this game you play inside a ...
3
votes
2answers
66 views

Linked list insertion

I have written the code below for inserting an element at the position specified by the user. I have seen the code in multiple books, and they have always used two pointers in the function that ...
8
votes
2answers
136 views

Smart pointer or how not to leak a pointer

Wrote a couple of blog articles about smart pointers. Unique Pointer Shared Pointer Constructors for Smart Pointers So I suppose it time to get the result reviewed. This is not supposed to be a ...
3
votes
2answers
809 views

Finding the min and max of an array, using a pointer

Modify the maxmin.c program so that the max min function uses a pointer instead of an integer to keep track of the current position in the array. maxmin.c ...
4
votes
2answers
114 views

A clone_ptr<T> that does not require T to have a clone method

Here is my clone pointer template: ...
2
votes
2answers
120 views

Build a time struct for current time in UTC

I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct ...
4
votes
2answers
233 views

Merge Sort in Perl

I'm new to Perl and have successfully written a merge sort program. I'll paste the entire program below, but would like mostly a review of the subroutines ...
15
votes
2answers
1k views

Can I buff up your file?

Here I have a method for reading the contents of a file into a buffer and returning whether or not it is successful. Here is what I would like reviewed: Speed: Am I reading in the file as fast as ...
-2
votes
2answers
185 views
2
votes
2answers
1k views

Implementation of unique_ptr and make_unique for aligned memory

I am working on a version of std::unique_ptr and std::make_unique for aligned memory. The purpose of this is vectorization, ...
1
vote
1answer
461 views

Casting between types for shared_ptr

I'm implementing an Entity-Component-System. Basically, an entity is a wrapper around an ID, a component is just a POD struct, and a System is a class that does work on components corresponding to the ...
0
votes
2answers
82 views

C++ smart pointer class

...
5
votes
1answer
413 views

Single LinkedList using smart pointers

In order to learn C++11, I propose to myself implement a simple single linked list using smart pointers. The idea was to cover the basic operations without leave any memory leak. I came up with a ...
8
votes
1answer
218 views

Implementation of a new kind of smart pointer in C++

I'm tempted to write a new kind of smart pointer which, I believe, is less intrusive than boost::intrusive_ptr and has the same memory footprint. The code for the ...
1
vote
3answers
171 views

Writing the function strend()

Due to being unable to ask a C programming language expert or advanced user in person, I'm posting this simple question about my C code. Today I was refreshing my C with exercise 5.4 of the C ...
3
votes
1answer
742 views

Remove odd valued nodes from linked list

The function remove_odd is to remove odd valued nodes (surprise!!) from the linked list head. The code is very long and cryptic but it seems to work. Please help ...
4
votes
1answer
130 views

Smart pointer mark II - my answer to C++ 11 shared_ptr

I am writing this smart pointer as a learning exercise. Any feedback would be most appreciated. Any flaws? Have I missed any test cases? smart_pointer.hpp: ...
6
votes
3answers
245 views

Reading, echoing, and returning integers in an array

I was wanting some clarification on my code, as I am new to pointers in C. I am trying to return an array from a simple function just so I can understand exactly what it is that I'm doing. Here is ...
4
votes
1answer
150 views

Truncate 160-bit output from SHA-1 to 64-bit uint64_t

I'd like to truncate 160-bit output from SHA-1 to receive a (weaker) 64-bit digest. It has been a while since I did the type of low-level C pointer arithmetic in the but-last line. Could you please ...
10
votes
3answers
2k views

Initializing and printing an array using pointers and dynamic allocation in C

I have written a code for basic array creation and printing it's values in C. I would appreciate comments on how it can be improved, and the industry standards. One issue I'm encountering is having ...
4
votes
2answers
423 views

C++ smart pointers and classes

I've started learning C++ recently and want from what I've gathered smart pointers are the way to go when storing stuff on the free store. I want to make sure I've got the basic hang of C++(11) ...
3
votes
1answer
46 views

Returning the next node

What is considered to be a good programming practice for returning value from the function? For example, if we have a function in C named ...
2
votes
1answer
89 views

Pointer handle - absolute follow-up

This is a follow-up to: Pointer handle - follow-up Pointer class/handle Please review my pointer class. ...
4
votes
2answers
86 views

Pointer handle - follow-up

This is a followup to: Pointer class/handle Please review this pointer class. ...