Hi,
I assume according to "Cocoa design patterns" book i'm reading that the retain function is implemented using something like this :
- (int)retainCount
// Returns the receiver's current reference count
{
int result = 1; // receiver not in table, its count is 1
void *tableValue = NSMapGet(
[[self class] _myRefCountMapTable], self);...
This is not so much a question on, "How do I pass it into the function?" but rather, "Is this acceptable?"
void func( int **ptr );
int main( int argc, char* argv[] )
{
int arr[][3] = {{1, 2,}, {3, 4}, {5, 6}};
int *pArr = *arr;
(&pArr[0])[1] = 3;
func(&pArr);
cin.get();
return 0;
}
void func( int **ptr )
{
...
Suppose we have a variable k which is equal 7:
int k=7;
int t=&k;
But this does not work. What's the mistake?
...
Hello everyone! For school I have to program a merge sort using only pointers.
I've tried almost everything, but I can not get it working.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define num_elementi(array) (sizeof(array)/sizeof(array[0]))
void selsort(int arr[],int n);
void swap(int * a, int * b);
void print(int a...
I am currently trying to allocate the same amount of memory for a double pointer. I take in a char** and want to use a bubble sort on that char** . So I create a temp char** and now I'm wondering how to correctly allocate enough memory so that I can return that temp char** to another method.
I know the way I'm allocating right now doe...
I'm doing a project where I struck against this situation:
typedef unsigned char Page[16384];
unsigned char Memory[16384*64]={...values...};
void foo(Page* page);
Now as you can see Memory is composed of "Pages", now I would like to pass a Page to a function but a Page should be a POINTER to values of Memory (so indexes of a Page shou...
I'm calling a C function using ctypes from Python. It returns a pointer to a struct, in memory allocated by the library (the application calls another function to free it later). I'm having trouble figuring out how to massage the function call to fit with ctypes. The struct looks like:
struct WLAN_INTERFACE_INFO_LIST {
DWORD ...
I have a constructor, that receives a character pointer. If it is empty, I need to set its member variable to NULL, however, the program crashes on exit when I try to.
I have verified that it gets to the line where it sets it to NULL and that is the cause of the crash.
I've tried the following:
val = NULL;
val = 0;
val = "";
Thos...
If I have a pointer that is pointing to an element in a vector, say element 2, and then that element gets swapped with element 4 of the same vector, Is the pointer now pointing to element 2, element 4, or neither? Example:
vector a is equal to [1,2,3,4,5]
create pointer that points to the element 2, which is equal to 3 in this case
sw...
I'm trying to remove an element from a vector.
vector<Foo> vecFoo;
Foo f1;
Foo f2;
Foo f3;
vecFoo.push_back(f1);
vecFoo.push_back(f2);
vecFoo.push_back(f3);
Foo* pF1 = &f1;
vecFoo.erase(std::remove(vecFoo.begin(), vecFoo.end(), *pF1), vecFoo.end());
That last line produces a huge amount of C2784 errors. What am I doing wrong?
(Ye...
I have grep function in C( embedded programming ) that takes a void pointer as a parameter. the function needs to be able to handle different kinds of types of variables like chars ints and longs. How can I code the function so it can figure out by itself what type of variable i am passing ?? I dont know if this is possible. thanks
ie. ...
Mmap returns a void*, but not a volatile void*. If I'm using mmap to map shared memory, then another process could be writing to that memory, which means two subsequent reads from the same memory location can yield different values -- the exact situation volatile is meant for. So why doesn't it return a volatile void*?
My best guess is ...
I'm writing a raytracer in C++ and need to be able to check intersections with every object in a scene (optimizations will come later), and to do this, I need to keep a running list of class instances. A list of pointers, updated when a new instance is created, won't work because as far as I know there is no way to increase the size of t...
SOLVED
Well, it seems that I'm receiving a segmentation fault when I try deleting my class pointer. I've tried many things, but yet haven't got it to work. Anyways, here is my
main.cpp: (this segmentation fault is occurring when I delete 'm')
/*
* Copyright(c)Fellixombc 2010
*
* TextToSqlRs is free software: you can redistribut...
I would like to synchronize two object headers with pointers.
For example: I know I can't do this with the current syntax, but I would like something like:
Node node = new Node();
node.Label = "header1";
TabItem tabItem = new TabItem;
*(tabItem.Header) = &(node.Label);
So whenever I change node.Label, tabItem.Header changes as well...
I've been studying the sample code Apple provides in their iPhoneCoreDataRecipes application and there are a couple of things they they're doing that I don't understand and I haven't been able to find a resource to help me with them.
Specifically, the block of code in question is:
- (void)tableView:(UITableView *)tableView didSelectRow...
debug src: http://www.cppblog.com/Files/mymsdn/cvector-bug-vs2008-201007101651.zip
Hey all, I have repair my code, thanks yours help! You can download the correct version of my code.
src: http://www.cppblog.com/Files/mymsdn/cvector-vs2008-20100710.rar
I am trying to write a C language version of vector. I use the void ** a the pRo...
I want to know about the pointer in C and C++ - how does it help in saving memory? I searched but did not get a satisfactory answer. Please help me out.
...
how does pointer in C++ helps in saving memory?
...
I have been trying to solve this problem the whole day:
How do I pass a double array to a function?
Here is an example:
int matrix[5][2] = { {1,2}, {3,4}, {5,6}, {7,8}, {9,10} };
And I wish to pass this matrix to function named eval_matrix,
void eval_matrix(int ?) {
...
}
I can't figure out what should be in place of ?
Can a...