pointers

Delphi - Accessing data from dynamic array that is populated from an untyped Pointer

Hi im using Delphi 2009 not that it has a large affect on what im doing i think I would run into the same if i was still on 2007. I have a scsi call that outputs data to a pointer (wrong way of looking at it but i have trouble explaining that). Originally i used Move to populate a Static Array of Byte with the data that came back, but ...

debugging with pointers in C#

When I programmed in C/C++, I often include pointer values in tracing. This helped correlate objects between trace messages. In C#, I don't have a pointer value available I can trace. Are there any good alternatives for traceable object IDs?? I don't know offhand how to get the underlying memory address, but even if I did that wouldn...

function pointers callbacks C

Hello, I have started to review callbacks. I found this link: http://stackoverflow.com/questions/142789/what-is-a-callback-in-c-and-how-are-they-implemented which has a good example of callback which is very similar to what we use at work. However, I have tried to get it to work, but I have many errors. #include <stdio.h> /* Is the ...

Mis-indexed char[] arrays in Visual Studio 2005

I'm at a loss to explain what seems to be mis-addressing within the char[] arrays of a C++ class I've inherited. I'm using Visual Studio 2005 and have narrowed the problem down to this: MyClass.h: class MyClass { public: MyClass(); virtual ~MyClass(); void Reset(); // More member functions. . . char m_szString[128]; // Mo...

Pointer problems with overloading in C++?

Pointers present some special problems for overload resolution. Say for example, void f(int* x) { ... } void f(char* x) { ...} int main() { f(0); } What is wrong with calling f(0)? How can I fix the function call for f(0)? ...

Why is the following C code illegal?

Consider a typical environment, why is the following code illegal in C? { int x; &x = (int*) malloc(3*sizeof(int)); ... } ...

Box-and-circle diagram of a double pointer?

Does anyone have a link to a box-and-circle diagram of a double pointer? ...

Delphi - Problem With Set String and PAnsiChar and Other Strings not Displaying

Hi. I was getting advice from Rob Kennedy and one of his suggestions that greatly increased the speed of an app I was working on was to use SetString and then load it into the VCL component that displayed it. I'm using Delphi 2009 so now that PChar is Unicode, SetString(OutputString, PChar(Output), OutputLength.Value); edtString.Text :...

Returning a pointer to a vector element in c++.

I have a vector of myObjects in global scope. I have a method which uses a std::vector<myObject>::const_iterator to traverse the vector, and doing some comparisons to find a specific element. Once I have found the required element, I want to be able to return a pointer to it (the vector exists in global scope). If I return &iterator, am...

What is ** in C++?

I've seen some code, as well as some errors generated from my compiler that have a '**' token before the variable (eg **variablename unreferenced-- or something, I can't recall exactly offhand). I'm fairly certain this is related to pointers, if I had to guess it looks like it's trying to dereference twice. '**' is fairly ungoogleable....

C++ Pointers to Member Functions Inheritance

I have a need to be able to have a super class execute callbacks defined by a class that inherits from it. I am relatively new to C++ and from what I can tell it looks like the subject of member-function-pointers is a very murky area. I have seen answers to questions and random blog posts that discuss all sorts of things, but I am not s...

Why 'this' is a pointer and not a reference?

I was reading the answers to this question C++ pros and cons and got this doubt while reading the comments. Why the this is a pointer a not a reference ? Any particular reason for making it a pointer? ...

Method in Objective-C that points to an object

I have created a few sprites using a spriteclass and I have loaded them into an array. In my app, I loop over the array checking for particular conditions (position, etc.). I want to create an explosion method that I can pass one of these objects to and then using the pointer pull the position of the object on the screen and show an expl...

Why can't I assign values to pointers?

After reading the faq's and everything else I can find, I'm still confused. If I have a char pointer that is initialised in this fashion: char *s = "Hello world!" The string is in read-only memory and I cannot change it like this: *s = 'W'; to make "Wello world!". This I understand, but I can't, for the life of me, understand how to...

Using a pointer to an object stored in a vector... c++

I have a vector of myObjects in global scope. std::vector<myObject> A method is passed a pointer to one of the elements in the vector. Can this method increment the pointer, to get to the next element, myObject* pmObj; ++pmObj; // the next element ?? or should it be passed an std::Vector<myObject>::iterator and increment that ins...

Duplicating arrays when equalizing Objects.

Greetings everyone. I'm in need of some experiance here as how to deal with dynamic arrays with Objects. I've a class 'SA', consisting of several objects 'Obj1', 'Obj2' etc... Within the class I have a dynamic array 'SA_Array' which I initialize in the following manner where size sets its length: double * SA_Array; SA_Array = new doub...

long integer as array index in C gives segmentation fault

Hello to all, The following C Code gives a segmentation fault: #include <stdio.h> #include <stdint.h> int main(){ uint32_t *a; uint32_t idx=1233245613; a[idx]=1233; return 0; } How can I use uint32_t as index of an array in C? Or how can I use array like structure which can get uint32_t and 12 digit n...

C++: Is it possible to share a pointer through forked processes?

I have a count variable that should get counted up by a few processes I forked and used/read by the mother process. I tried to create a pointer in my main() function of the mother process and count that pointer up in the forked children. That does not work! Every child seems to have it's own copy even though the address is the same in ...

pointer to objects within a class, C++ newbie question

why in C++, for objects A,B //interface, case #1 class A { B bb; } A::A() { //constructor bb = B(); } //interface, case #2 class A { B *bb; } A::A() { //constructor bb = new B(); } Why case #2 work but not #1?? Edit: I got it now. But for case #1, if an instance of A is freed, will its bb also be automatically freed? Case #2 yo...

Pointer to a MFC dialog class

Hello, Can someone please guide me on how to pass the reference pointer to the dialog class so that it can call DoModal? e.g. EditorSvr.cpp -- implementation of the interface class (which is also located in a DLL) CDialogClass1.cpp -- Dialog class that will receive the pointer from EditorSvr.cpp I tried to search the whole google bu...