Category "pointers"

Does adding a star after a pointer struct definition make it a double pointer?

I have a struct typedef struct hash_entry_{ char *string; void *data; struct hash_entry *next; }hash_entry, *p_entry; I am referencing p_entry later i

Deleting a pointer from a vector... Error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

I'm getting the error after I delete a pointer from the vector and try to delete a second one. I'm still new to pointers I created a base class of shapes and ha

C : why is that cast of void function to "pointer to function returning pointer to pointer to void" possible

#include <stdio.h> void hello() { printf("hello world\n"); } int main() { void *(*gibberish)() = (void *(*)())hello; (*gibberish)(); voi

How to detect if a block of memory already freed

I already know that there is no way to know if a pointer target still a valid allocation of it's already freed, so I'm trying to use pointer to pointer to solve

Passing and Returning a 2D array of unknown size in C++

I want to pass and return a 2D array of unknown size but I donot know how to do it. I know how to only return array of unknown size only (array of pointers). I

What is cryptic line of code for this statement? [closed]

For example: temp->next = NULL is same as (*temp).next = NULL list->next->next = temp is same as ??

How can I declare a Pointer to a struct in C?

I have learned that pointers can be declared in 3 different ways: int* a; int *b; int * c; I prefer: int* a; While declaring a pointer to a structure, is it c

How to judge whether the incoming buffer is valid in C++?

In my function, a memory pointer and its size are passed as parameters: int myFun(uintptr_t* mem_ptr, int mem_size) { // Code here } Is there any way to te

Invalid conversion from char * to int fpermissive

#include<iostream> #include<vector> using namespace std; int main(int argc,char** argv){ int n; if(argc>1) n=argv[0]; int* stuff=new int[n];

My pointer does not point on the same value when its call in a slot QT C++

I do a pokemon project with a Qt interface. I created a class Trainer and Pokemon : class Pokemon { protected: string itsName; doub

why is the output 1 in this case and when i am doing t-p then its giving me -1

As you can see it is giving me 1 but why? When i do t-p then it gives me -1 . Why ? int f=4, o=8; int *p, *t; p = &f; t = &o; printf("Difference betwee

How can I achieve something similar to a pointer to a string in javascript?

Is there a concept like a pointer to a string in javascript? Or how would this be done? let s1 = "hi"; let s2 = "bye"; // I want to write my code like this [,]

How can I create a 2D array of chars with POINTERS in C?

I'm trying to create a program which the user inputs the number of items (rows) and give each one of them a name (scanf) with the max of 30 characters. I want t

C Pointer Arithmetic for Unusual Architectures

I'm trying to get a better understanding of the C standard. In particular I am interested in how pointer arithmetic might work in an implementation for an unusu

Setting a pointer to a specific array and/or struct element

Here is the scenario: I have an array, AllElements of structure ElementSet, and inside of that structure - is a set of myElement structures and also an array of

How to save/load values from board to file

Im using c++ 11, I need to save/load array to and from file. Its the battleship game its need to be done for both user and computer array but i have no idea how

C++ Read txt and put each line into Dynamic Array

I am trying to read input.txt file, and trying to put each line into the array as string (later on I will use each element of array in initializing obj that's w

Why is "std::is_pointer<std::nullptr_t>::value" equal to false?

I read about std::is_pointer in C++. Then I wrote the program and check whether T is a pointer type or not using std::is_pointer. #include <iostream> i

Copying a certain number of characters from one pointer to another

I have a source pointer (pSource) and a goal pointer (pGoal). I also have a number of characters (n) that need to be copied to the pGoal from pSource. I thought

I try to use placement new, but always complies error

#include <iostream> #include <new> const int BUF = 512; const int N = 5; char buffer[BUF]; int main(){ using n