pointers

Pointers to functions

Hello, I have to pass function into pointer. For this purposes I'm using boost::function. The function which catches the pointer is overloaded for different signatures. For example: void Foo(boost::function<int ()>) { ... } void Foo(boost::function<float ()>) { ... } void Foo(boost::function<double ()>) { ... } Now I wanna pass some c...

Getting my conceptions about pointers and references straight (C++)

Hi guys I've been programming a while now at school, and I'm working on my first independent large project. I've been discovering a lot of things about programming that I haven't known before and it's been great. However, more and more, I feel like I no longer understand C++ as a language the more I delve into it. I'd like to get some ...

Do pointers exist in .NET?

Hi, I want to know if pointers exist in .NET technology. If yes, is there any example for pointers in C#? Please guide me . ...

How to validate length of received byte array, which is not null terminated?

Hi all, I have a C\C++ code that receives a structure over the network, from this form: struct DataStruct { int DataLen; BYTE* Data; } The code I have runs over Data in a loop of DataLen times and processes the data. ...The problem: After the code came to security experts for penetration tests, they prepared a fake application whic...

Assignment from incomplete pointer type

Good evening, everyone. I've now run into an odd warning, and for the life of me I can't figure out where it's going wrong. I've tried so many different options I can't remember. The error is: assignment from incompatible pointer type Relative code: // Server structure typedef struct { struct addrinfo address; // Addr...

get address of array of pointers to pointers to char

Hello, gcc 4.4.3 c89 I am trying to display the address. Basically, I just want to prove that I am displaying the correct address. I want to display the address of each array of pointers to char 'device_gc', 'device_mg', 'device_cc' So I display them in my main function. However, in my display_list function I just want to prove I am ...

To "head" or NOT to "head"?.

I have a "pointer" which keeps incrementing and I need to return the "head" of the pointer finally. I am in a dilemma to use either "pointer[0]" or have another variable called "head" and initialize it and return at the end. The former I feel makes the code looks soiled and later costs little memory. Any clean suggestion? ...

Can a C++ compiler optimize away code when dealing with pointers?

Hello, With these two questions as background (first and second), I got curious about how much optimization a C++ compiler can perform when dealing with pointers? More specifically, I'm interested in how smart a compiler is when it optimizes away code which it may detect will never be run. (Some may point out that this is a dupe of thi...

Pointer mismatch for actual parameter?

I have a function which creates an array of pointers. The function which allocates the memory returns the new memory pointer through a parameter passed to the function. The simplest code which can reproduce the problem is as follows: void foo (void** new_mem, size_t bytes) { *new_mem = malloc(bytes); } int main (void) { int**...

Accessing the content of a variable array with ctypes.

Hi there, I use ctypes to access a file reading C function in python. As the read data is huge and unknown in size I use **float in C . int read_file(const char *file,int *n_,int *m_,float **data_) {...} The functions mallocs an 2d array, called data, of the appropriate size, here n and m, and copies the values to the referenced ones...

Smart Pointer Implementation in C

Possible Duplicate: Smart pointers/safe memory management for C? I have an embedded application where I am allocating an object in dynamic memory and passing it around to other modules. I would like to create a smart pointer to this object. There are many examples in C++ for using and implementing smart pointers. I am l...

Pass by Reference v. Pass by Pointer -- Merits?

Possible Duplicates: When pass-by-pointer is preferred to pass-by-reference in C++? Are there benefits of passing by pointer over passing by reference in C++? How to pass objects to functions in C++? Hi all, I'm working to develop a large object oriented c++ application framework as part of my chemical engineering graduate...

Game Development - Array with pointers to array elements

I am currently developing a game for the iPhone/iPod/iPad. To store the board data, which is 12 columns by 8 rows, I have an array that stores pointers to one of the game items, a block. It is declared as follows: BlockData* mBoard[kNumberOfColumns][kNumberOfRows]; I also have another array declared like this: BlockData* mCenterSqu...

Any tips for dealing with a very small stack?

I was wondering if any developers in the embedded space know of any interesting tricks to help lessen the pain of developing for microcontrollers with very limited stack space. I've recently been writing some firmware for 8-bit uCs (Microchip PIC18F family, 31 byte stack) and as a consequence I have had to flatten my programs and reduce...

Marshalling between C# and C++, and the Juggling of Responsibilities

Hello everybody, what if I had a native C++ function in which, depending on the result of the function, the responsibility of deleting a certain pointer (delete[]) differs between the caller and the function. I would of course check for the return value and act accordingly in C++. Question is, what if the function was marshalled between...

Another C Pointer Question

I thought that I was really starting to understand how pointers work, and then I came across this exercise. I was trying to recreate a chunk of code that I found in my 'Learn C' book and I got it done and it was working and I thought everything was great: void PrintWords( char *line ) { bool inWord = false; while (*line != kB...

Pointer to members

In following code consider the statement :- "int B::*bpm;" class B { public : int bi; }; class D : public B { }; int main() { D obj; int B::*bpm; bpm = &B::bi; obj.*bpm = 1; return 0; } When to use "Pointer to members" in design/code to improve my design/coding practice. * ...

Efficient pointer to integer mapping and lookup in C++.

I want to map pointer to integer for purpose of serialization. The pointers may be of different types and may point to polymorphic objects possibly using multiple inheritance. I need to query the map to know if the pointer is stored in it and if it is, then what is the associated integral value. What is the correct way to do it? The si...

How to get the C pointer array length?

Is there any method like the Java can .length from a C point array? Thank you. ...

why different answers?

Below are 2 programs First #include<stdio.h> void main() { int a[5]={1,2,3,4,5}; int *p; p=&a; printf("%u %u",p,p+1); } Second #include<stdio.h> void main() { int a[5]={1,2,3,4,5}; printf("%u %u",&a,&a+1); } Now, in the two programs..I have printed the values of &a using p in first code and directly in th...