pointers

Vector iterator

I have class CBase { ....... }; class CDerived : public CBase { ...... }; vector<CBase*> mpBase; vector<CDerived*>::iterator InfoIt; InfoIt=mpBase.begin(); VC++ 2008 generates error C2679. What's wrong? ...

Split UInt32 (audio frame) into two SInt16s (left and right)?

Total noob to anything lower-level than Java, diving into iPhone audio, and realing from all of the casting/pointers/raw memory access. I'm working with some example code wich reads a WAV file from disc and returns stereo samples as single UInt32 values. If I understand correctly, this is just a convenient way to return the 32 bits of m...

objective c id *

I am using the KVO validations in my cocoa app. I have a method - (BOOL)validateName:(id *)ioValue error:(NSError **)outError My controls can now have their bindings validate. How do I invoke that method with a id * NOT id To use the value that is passed in (a pointer to a string pointer) I call this: NSString * newName = (NSString ...

Store address dynamic array in c

I'm trying to save the address of a dynamic array index. The last line of this function is what gives the pointer error. static struct sstor *dlist struct node *ins_llist(char *data, struct llist *l) { struct node *p, *q; q = malloc((size_t)sizeof(struct node)); if(q == NULL) return(NULL); if(ins_list(data, &dli...

Finding dimensions of a 2D array in C using pointers

I create a 2D array in C as follows: int **arr; arr = malloc(rows * sizeof(int *)); for (i = 0; i < rows; i++) arr[i] = malloc(cols * sizeof(int)); Now, I call: func(arr) In the function func, how do I calculate the row and column dimensions? ...

asterisk in variable declaration in headers in obj-c

I get that asterix is for pointers, and I understand about pointers now. But I'm still not sure why when declaring a variable in a header I need to use an asterix, for example: UINavigationController * navController; why isn't that: UINavigationController navController; Thanks ...

Noob pointer/array question

I know this is probably a stupid question, but I need to be sure; I came accross some legacy code that contains a function like this: LPCTSTR returnString() { char buffer[50000]; LPCTSTR t; /*Some code here that copies some string into buffer*/ t = buffer; return t; } Now, I strongly suspect that this is wrong. ...

how 'free' works when pointer is incremented

When malloc is called, the size is stored adjacent to the allocated block so that free will know how much to free etc ( http://c-faq.com/malloc/freesize.html ). My question is, Say we have dynamically allocated memory and later in the code we increment the pointer pointer++ And then later, if i call a free(pointer) what memor...

Alternatives to C++ Reference/Pointer Syntax

What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right readin...

How to declare a pointer to a variable as a parameter of a function in C++?

I have a function that takes a const D3DVECTOR3 *pos, but I have no reason to declare this beforehand. The most logical solution to me was using new: Function( //other parameters, new D3DXVECTOR3(x, y, 0)); but I don't know how I would go about deleting it, beign intitialized in a function. My next thought was to use the & o...

What is the difference between freeing the pointer and assigning it to NULL?

Could somebody tell me the difference between: int *p; p=(int*)malloc(10*sizeof(int)); free(p); or int *p; p=(int*)malloc(10*sizeof(int)); p=NULL; ...

How to set cursor position in C on linux?

Hi all, how can I set the mouse cursor position in an X window using a C program under Linux? thanks :) (like setcursorpos() in WIN) EDIT: I've tried this code, but doesn't work: #include <curses.h> main(){ move(100, 100); refresh(); } ...

C++ Access derived class member from base class pointer

class Base { public: int base_int; }; class Derived : public Base { public: int derived_int }; Base* basepointer = new Derived(); basepointer-> //Access derived_int here, is it possible? If so, then how? ...

Excel formula to show linked cell ID

In an excel cell, I've placed a simple formula =C4 The cell typically displays the value of cell C4, but instead I want to see the linked cell ID instead, which in this case is "C4". Is there a formula to show me this? like: =SHOWCELL(C4) The reason I need this instead of simply typing the value of "C4" into the cell, is so Excel ...

Does Function pointer make the program slow?

Hi guys. I read about function pointers in C. And everyone said that will make my program run slow. Is it true? I made a program to check it. And I got the same results on both cases. (measure the time.) So, is it bad to use function pointer? Thanks in advance. To response for some guys. I said 'run slow' for the time that I have comp...

Go: using a pointer to array

I'm having a little play with google's Go language, and I've run into something which is fairly basic in C but doesn't seem to be covered in the documentation I've seen so far When I pass a pointer to an array to a function, I presumed we'd have some way to access it as follows: func conv(x []int, xlen int, h []int, hlen int, y *[]int)...

Linked List exercise, what am I doing wrong?

Hey all. I'm doing a linked list exercise that involves dynamic memory allocation, pointers, classes, and exceptions. Would someone be willing to critique it and tell me what I did wrong and what I should have done better both with regards to style and to those subjects I listed above? /* Linked List exercise */ #include <iostream>...

pointers in haskell?

hi, do you know if are there pointers in haskell? -If yes, how do you use them? Are there any problems with them? And why aren't they popular? -If no, is there any reason for it? Please help us!! :) Thank you so much!! ...

C# wrapper for array of three pointers

I'm currently working on a C# wrapper to work with Dallmeier Common API light. See previous posting: http://stackoverflow.com/questions/2430089/c-wrapper-and-callbacks I've got pretty much everything 'wrapped' but I'm stuck on wrapping a callback which contains an array of three pointers & an array integers: dlm_setYUVDataCllback in...

Basic help needed with pointers (double indirection)

Hi, i asked some time ago on an account i cant remember how to manipulate basic pointers and someone gave me a really good demo for example char *ptr = "hello" (hello = a char array) so now *ptr is pointing at h ptr++ = moves the ptr to point at the next element, to get its value i do *ptr and that gives me e ok so far i hope :D ...