Questions tagged [pointers]

Data types for "pointing" at other values: A pointer's value is a memory address where the pointed-to value is stored. This tag should be used for questions involving the use of pointers, not references. Common programming languages using pointers are C, C++, Go, and assembly and intermediate-representation languages; use a specific language tag. Other helpful tags should describe what is being pointed-to (e.g. a function, a struct etc.)

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

free'ing after allocation seems to crash my code in interplay with intel's mkl_sparse library

I am currently updating a piece of Code that eventually should be used inside a loop for time evolution. I have encountered some problems thatseem to come down to the notorious pointer allocation and ...
Peter Sanctus's user avatar
0 votes
0 answers
17 views

EXC_BAD_ACCESS Error When Using Lambda Callback in C++ SocketIO Client

I am developing a class in C++ that involves handling SocketIO events. The class contains a method that binds an event to a function using a lambda. This lambda captures this in the constructor of the ...
Lemos's user avatar
  • 1
0 votes
0 answers
66 views

C++ Game Pointer Address changes to Offsets not the value address

I made a code that should give me the value of the pointer address. For that i "build" the address but the address is always only the offset of the pointer address. Cant figure out why i ...
Chraydragon's user avatar
0 votes
0 answers
71 views

Unexpected behavior with pointer assignment [closed]

I'm getting unexpected behavior from a small portion of a C function with assigning values to an array of pointers. Code snippet: int input_arr[512]; for (int k = 0; k < 512; ++k) ...
Nathan Schmidt's user avatar
-1 votes
0 answers
36 views

Error accessing memory sent from windows driver to user app

I am sending some ip addresses to user mode from windows driver by allocating dynamic memory to the buffer. I am copying memory to buffer successfully but getting error when I try to access the memory....
vk_'s user avatar
  • 43
0 votes
0 answers
47 views

[Python][CE7.5] Justification with the offset calculation

I'm currently working my way into Process Memory with Python. Now I have created a pointer with Cheat Engine as you can see here in the photo: https://i.imgur.com/D2nIrOP.png . After hours of ...
Coffee's user avatar
  • 19
-2 votes
1 answer
73 views

C++ What's the impact of the relationship between asterisks and parentheses on the definition of multidimensional arrays [closed]

I am learning C++ for the first time with the book C++ Primer. I found it difficult to grasp the syntax for declaring pointer and array types. This started in Chapter 3, where the type alias of ...
Emiya Elien's user avatar
1 vote
3 answers
82 views

Does passing arrays as parameters causing segmentation fault?

This is a simple program to find the smallest element of an array. But the previous versions of the following program gave an error where the smallest and largest numbers were displayed as 0. In the ...
Varun G's user avatar
  • 11
-4 votes
0 answers
59 views

2x2 Rubiks Cube Checker in C [closed]

I need help with coding a simple Rubik's Cube Checker in C. It means the following: The standard cube (starting point) is defined by the array: char rubik[6][2][2] and the input (rubiks cube) over the ...
Jeremy Gruhnert's user avatar
2 votes
1 answer
106 views

C# multiple arrays with the same memory

Is it possible in C# to have multiple arrays at the same memory location with the arrays having different types? I have a large float array, and I need to convert it to a byte array in as short a time ...
Plat00n's user avatar
  • 117
-1 votes
2 answers
106 views

In C, how do you know if the argument passed is a list or a pointer? [closed]

So I was working on Codewars and I got given void func(const struct struct_name *name) to work with. So I wondered, in other general cases, how would I know if it's just a pointer to a particular ...
Harshvardhan Thakkar's user avatar
-1 votes
0 answers
37 views

Why am I getting "EXC_BAD_ACCESS" when trying to change pointer value in AVL tree | nodeptr->right = newptr |?

I'm new to C++ and trying to create an AVL tree to get some experience. And I'm trying to change the "right" pointer of a node instance with nodeptr->right = newptr but I get ...
iron9fist's user avatar
0 votes
0 answers
53 views

Modifying in-class pointed objects through array of base pointers

I have a model who has (for now double) parameters and produces a double output : class Model1 { double x_; double y_; std::array<double*, 2> model_parameters; void ...
11house's user avatar
  • 83
-1 votes
0 answers
34 views

How to encode/decode slice of pointer while not exceeding the output length in golang? [closed]

I want to implement encoding/decoding to my go project: Encode function: take slice of string pointers and encode it to string Note: the output should not exceed 450 chars no matter how big the slice. ...
devi's user avatar
  • 40
-1 votes
0 answers
78 views

Why does my program always leak memory around item 20 on the line items? [closed]

I apologize for what's probably a dumb question. I'm relatively new to C. In any event, I was attempting to make a program that returns each permutation of a number. For some reason, my program ...
Ratdude's user avatar
  • 21
-3 votes
0 answers
60 views

how do i solve this nullptr exception in c++? [closed]

I'm trying to return a memory address in this method, but it throws an exception that the pointer in file is null Skins* Lugar::getSkin() { this->skins->setSkinFiles("rutas_fondo....
Jesus's user avatar
  • 1
1 vote
3 answers
41 views

Getting incompatible pointer type warning because the return of the function is not void* but a struct pointer

This warning seems to not be necessary. In my code, I have a function pointer type (void*)(*function_pointer)(void* data) and some functions require function pointers of this type as a parameter, ...
Vulgo's user avatar
  • 25
-2 votes
1 answer
64 views

How to use (double) pointer to update value of other pointer

I am trying to merge an array of individually sorted linked lists together to one sorted linked list (this is Leetcode problem 23, BTW). The linked list is defined as: struct ListNode { int val; ...
Tim's user avatar
  • 11
1 vote
0 answers
70 views

(*p)->left->prev means *p

I wrote a red-black tree program implementation. I ran into a problem in the left_rotation function. void left_rotation(node **p) { node *left_son = LEFT_SON_VAR_PAR; /* (*p)->left */ node *...
Fyodor's user avatar
  • 39
-2 votes
0 answers
102 views

Valgrind shows mutiple memory leak in copy constructor despite having a destructor [closed]

Status.h #ifndef SDDS_STATUS_H #define SDDS_STATUS_H #include<iostream> #include<cstring> namespace sdds { class Status { char* description; int status_code; ...
ShiShir 89's user avatar
0 votes
1 answer
104 views

Why would it be necessary to use (&*ptr) this format?

I am reading sample code regarding to how to write destroy(): template<class T> inline void destroy(T* pointer) { pointer->~T(); } template <class FowardIterator> inline void ...
Yiqun Cui's user avatar
2 votes
1 answer
88 views

Mysterious (I think) buffer over run in C

Sorry if this is a duplicate post. I am currently having an issue where I am getting a warning on this piece of code saying C6386: Buffer overrun while writing to 'titleTextPointer' but I'm fairly ...
osbourne clark's user avatar
0 votes
0 answers
14 views

Copying a Google Sheets file doesn't copy the old file's macros? How do I

This time last year, my hard drive crashed and I had to buy a new PC. I've used Excel 2002 for many years, so I got out the CDs and installed it on the new machine. Unfortunately, the update packs are ...
R. Lambert's user avatar
0 votes
0 answers
17 views

Need help in understanding a pseudocode aiming to insert a new element in the beginning of a linked list

I was studying about Linked Lists from the book, "Introduction to Algorithms" by T Cormen. There was an portion in the book as follows: Given an element x in the list, x.next points to its ...
Thomas Finley's user avatar
-4 votes
0 answers
54 views

Why the code doesn't work when I add "\n" at the end of first printf statement [closed]

\n problem at the end of first printf. please provide a suitable answer as I am a beginner in the coding world. i was trying to write a code of asking an integer p such that 3<p<20 and printing ...
Mintu Boro's user avatar
-1 votes
0 answers
57 views

Access violation reading location when using Dynamic Arrays

I have made a dynamic Array and am hoping to retrieve data from it. Yet all I get is the error: Access violation reading location The main problem seems to be at lab12-2.cpp(62,48) Here is Main File: ...
Dylan Winger's user avatar
0 votes
1 answer
80 views

Pass a Pointer or Ref to the constructor of an object

Fairly new to C++ and having an issue with ref vs. pointer. The code below is a class for a simple motor and works. I would like to pass the pin expander in the constructor, but cannot seem to get ...
WouldRatherBuildAMotor's user avatar
0 votes
1 answer
81 views

golang strange allocations in slice of pointers

I have simple benchmark to compare performance for creating slice of structs and slice of pointers to that structs package pointer import ( "testing" ) type smallStruct struct { ID ...
Dmitry Ermichev's user avatar
1 vote
1 answer
61 views

How to implemented comparison/less operator for member method pointers?

From my reading, I understand that it is possible to compare some pointer types in C++ using either operator< or std::less. This is useful if, for example, a pointer is used as a key for a std::...
Patrick Wright's user avatar
2 votes
2 answers
109 views

How do initial members, common initial sequences, anonymous unions, and strict aliasing interact in C?

So there are several things that are clearly allowed under the strict aliasing rules (for clarity, lets do this in C23): The first and most obvious is that structs are allowed to alias with pointers ...
nickelpro's user avatar
  • 2,635
0 votes
0 answers
41 views

Wrapping up a vector to pointer parameters

I have a Model type that has double "parameters" and a vector of pointers to them, vector that I use for shifting up and back down the parameters to see how some member function depends on ...
11house's user avatar
  • 83
0 votes
0 answers
42 views

Best way to reference a subset of instances in a map?

I am working on multibody simulations. In my code's hierarchy, a (physical) System has several RigidBodys stored in a table std::map<std::string, RigidBody>. Each RigidBody instance similarly ...
dme48's user avatar
  • 1
2 votes
2 answers
123 views

Pointer of number in C

Assume there's function that get int * parameter. void foo(int *x) { } If I want to call this function without creating an int variable int main() { foo(&1); return 0; } compilation ...
Ertugrul's user avatar
  • 124
0 votes
0 answers
37 views

the ability to modify a string that is stored inside pointer and modify array, what is the different? [duplicate]

I have two pointer (str) and another (str1), the first str is a pointer store string (char *str = "hello") and (char str1[]= "hello"). during one code I try to modify the values ...
dhiman shubham's user avatar
0 votes
2 answers
70 views

Does multiple pointer allocation may cause an overflow?

I'm trying to understand memory management with C. So far I have a clear overview, but there's a question that is not that obvious for me. If I declare a char pointer and assign it some string, then ...
Edher Carbajal's user avatar
-3 votes
2 answers
108 views

Unable to resolve segmentation Fault in C program

My assignment is to write a C function void censor(char *start) that will replace all 4 letter words in the string pointed to by start with ****. Assume that words are delimited by blank chars. The ...
goldengomi's user avatar
-1 votes
0 answers
17 views

Working with audio files and reversing and changing playback speed [closed]

#include <stdio.h> #include <stdlib.h> void reverseAudio(short** data, int numSamples) { for (int i = 0; i < numSamples / 2; ++i) { short tempL = data[i][0]; short ...
alex duarte's user avatar
1 vote
2 answers
84 views

How do I create an array of class pointers with new?

I'm a little bit confused. I have this code: class Fish { public: void Swim() { std::cout << "I'm Swiming" << std::endl; } }; Now, in another ...
Lucas 's user avatar
  • 341
-1 votes
0 answers
41 views

style.cursor ='pointer' when hovering to a button doesn't work in javascript

my style.cursor ='pointer' when hovering to a button doesn't work. Can anyone assist me on how to achieve this please? (function() { 'use strict'; // Function to launch a webpage function ...
The Code Explorer's user avatar
0 votes
1 answer
21 views

everything works well except for when i give selection 3 as set dosa, it takes that input as invalid although it isnt

These are some variations of the code, the output is the same in all the variations. Ive tried using pointers and also by defining a function caseInsensitiveComparision and also by some minor changes ...
Varun G's user avatar
  • 11
0 votes
0 answers
12 views

Cloudflare DNS PTR Record Issue with Specific Email Providers

we have a problem that after activating Cloudflare, some of our emails are not sent to certain email providers like freenet.de we recieve the folloing log: [email protected]: host emig.freenet.de[195....
Ehsan Moradpour's user avatar
2 votes
3 answers
125 views

How to use a memory allocation with different variable types in c?

I would like to have memory allocated with different type of variables inside. At the moment, I have this code: //key=4bytes(char), name= 4chars=4bytes, age=4bytes ==>12* 20 elements ...
R.Duarte's user avatar
0 votes
1 answer
110 views

How to understand slices in structs in Golang

I'm new to Golang and I'm trying to understand pointers type deque struct { indexes []int } func (d *deque) push(i int) { d.indexes = append(d.indexes, i) } the indexes here is a slice ...
Tian Gao's user avatar
0 votes
2 answers
53 views

Accesing to value of 2D array using pointer arithmetic

I'm studying multy-pointers and I watched this video, where explains that, if we want to access the value of a 2D array, we use double indirection like this: #include <stdio.h> #include <...
Daniel Muñoz's user avatar
4 votes
1 answer
186 views

void* ptr = &func; compiles with msvc without any diagnostic but both gcc and clang rejects it

I am learning C++ using the book "C++ Primer" by Stanley. In particular, the section about "pointer conversions" says: a pointer to any nonconst type can be converted to void* ...
Alan's user avatar
  • 574
2 votes
2 answers
56 views

Dereferencing pointer cast from an integer of a valid memory address give Segmentation fault

I was playing around with c pointer and wrote this code #include <stdio.h> int main() { int a = 17; int* p1 = &a; int* p2 = (int*)(&p1); p1 = (int*)(&p2); printf(...
twowr's user avatar
  • 21
1 vote
2 answers
81 views

keep only the rows l, l+1, ... ,r in the matrix and deallocate the rest

I want to keep only the rows l, l+1, ... r in the matrix and deallocate the rest ex: 1 2 3 4 5 6 7 8 9 0 1 2 for l=1 and r=2 the output is: 5 6 7 8 9 0 1 2 This is what I tried: void select_rows(...
Didi's user avatar
  • 47
1 vote
1 answer
68 views

How to Make a Function Returns Pointer to Array of Function Pointers

on this follow program I've tried to make a function that returns a pointer to array of 4 function pointers but I don't know the way how it works and how can I call it and receive the return value ...
M_G_0xFF's user avatar
4 votes
2 answers
190 views

Why does a pointer to a base class with a different address compare equal to the derived class pointer

The standard defines pointer comparison like this basically from [expr.eq#3] Otherwise, if the pointers are both null, both point to the same function, or both represent the same address, they ...
minex's user avatar
  • 424
0 votes
1 answer
58 views

Value of pointer variable changing when value stored in succeding locations is modified

This is the C code I executed. int *a, *b,*c,d; a=&d; printf("1 a=%p &d=%p\n", a,&d); b=a+1; printf("2 a=%p &d=%p b=%p\n", a,&d,b); c=a+...
Gurjot Singh's user avatar

1
2 3 4 5
1129