pointers Questions

2

Solved

There is a strange behavior of lobstr::obj_addr caused by its vectorization over lists, when the list itself doesn't change the address. I just started Advanced R by Wickham (2ed) and reached the 2...
Brambling asked 16/9 at 16:19

6

Solved

I have a char array that is really used as a byte array and not for storing text. In the array, there are two specific bytes that represent a numeric value that I need to store into an unsigned int...
Sarcocarp asked 25/10, 2011 at 17:12

3

I know how to get the value of a variable by its id in Python like: a = "hello world!" ctypes.cast(id(a), ctypes.py_object).value I wonder if it possible to overwrite the variables value by id? ...
Electrophilic asked 15/4, 2018 at 11:51

4

Solved

Let's say that I have a main class SomeManager for keeping track of instances of another class SomeClass. When SomeClass is constructed it calls a method of SomeManager passing a pointer to itself....
Snow asked 13/2, 2015 at 4:8

3

There are three ways to pass an array to a function 1. void changeArray(int array[]) { array[0] = 1111; } void changeArrayByPointer(int * array) { array[0] = 1111; } void changeArray(int ...
Watkins asked 20/8 at 4:14

8

Solved

Are array of pointers to different types possible in c++? with example please)
Showbread asked 16/10, 2009 at 18:57

3

Solved

I'm implementing an A* pathfinding algorithm in C++ to solve a maze, but I'm encountering a segmentation fault (SIGSEGV) when the maze size is high (~10,000x10,000 or larger). The error occurs in ...

3

Solved

I have a function that is used to allocate a buffer with given size. The buffer will be preprocess/filled some data before return. This preprocess may return false to represent this buffer is not p...
China asked 22/10, 2015 at 6:48

6

Solved

I think this is a really easy thing to code, but I'm having trouble with the syntax in C, I've just programmed in C++. #include <stdio.h> #include <stdlib.h> void pointerFuncA(int* ip...
Monstrance asked 2/10, 2015 at 19:15

4

Solved

In C one can have string literals in the form of char *string = "string here"; integer literals: uint8_t num = 5; long literals: long long bigNum = 90322L; floating point literals: float...
Kafka asked 13/6, 2014 at 19:42

6

Solved

I have a question on how pointers to a custom object are handled when used as Keys in an map. More specifically if I define std::map< CustomClass*, int > foo; Would the default C++ implem...
Recalcitrate asked 4/8, 2014 at 16:6

2

The C Standard defines lvalue as: An lvalue is an expression (with an object type other than void) that potentially designates an object;64) if an lvalue does not designate an object when it is ev...
Accommodation asked 27/6 at 6:16

3

Solved

In this answer to this question, it was noted that: If you're going to 'clear' the pointer in the dtor, a different idiom would be better - set the pointer to a known bad pointer value. and also ...
Macneil asked 24/6 at 19:23

4

Solved

I have this: vector<Object*> myVec; and adding my objects to it like this: Object *obj1 = new Object; myVec.push_back(obj1); Let's assume that I have 100 objects in this way and pointer...
Purposeful asked 25/10, 2014 at 21:59

9

Solved

I have looked around but have been unable to find a solution to what must be a well asked question. Here is the code I have: #include <stdlib.h> struct my_struct { int n; char s[] }; in...
Seymour asked 13/1, 2010 at 23:2

3

Solved

I was hitting an issue in a project I'm working on. I found a way around it, but I wasn't sure why my solution worked. I'm hoping that someone more experience with how Go pointers work could help m...
Yabber asked 28/4, 2015 at 15:45

5

Solved

typedef char* c; const c ptr1 = "pointer"; ++ptr1; /// error const char* ptr2 = "pointer"; ++ptr2; /// runs fine Now ptr1 should be of type const char* and thus a non-const pointer, then why is i...
Hanahanae asked 8/8, 2012 at 12:53

6

Solved

It's fairly common knowledge that if you access an element of an array as arr[i] in C that you can also access the element as i[arr], because these just boil down to *(arr + i) and addition is comm...
Million asked 24/8, 2011 at 19:58

5

I would like to call C functions (e.g. form the stdlib, math ...) dynamically. This means that my C program only knows the pointer to a random function (e.g. printf) and its signature (coded as a c...
Rivulet asked 12/3, 2013 at 22:24

5

Solved

I thought I've read somewhere that when using pointers and we want to copy the content of one to another that there are two options: using memcpy or just assigning them with = ? However in the ...
Choreodrama asked 9/10, 2016 at 0:3

1

Solved

Can I declare a C pointer with an intialization to its own address? void* p = &p; I am specifically concerned with if this is strictly standard compliant in C23 (as the draft currently stands)....
Coelostat asked 6/4 at 4:34

20

Solved

Can we check whether a pointer passed to a function is allocated with memory or not in C? I have wriiten my own function in C which accepts a character pointer - buf [pointer to a buffer] and size...
Rockhampton asked 16/10, 2009 at 5:46

24

Solved

I'm coming from a Java background and have started working with objects in C++. But one thing that occurred to me is that people often use pointers to objects rather than the objects themselves, fo...
Aloise asked 3/3, 2014 at 11:54

7

Solved

I am little bit confused about pointers and how many bytes they take up. In my textbook it first says that pointers on 16 bit systems take up 2 bytes, 32 bit systems 4 bytes, 64 bit system 8 bytes ...
Methedrine asked 24/12, 2013 at 16:1

5

Solved

Edit: Thanks, amazing help, as always :) I can't find the solution to this, I have an unique_ptr to a base class, that has the data of a derived class, and I want to set it's type to the derived c...
Phineas asked 11/11, 2015 at 11:24

© 2022 - 2024 — McMap. All rights reserved.