void-pointers

    -1热度

    1回答

    你好,我有这个问题。我做了这个功能: void* deque2array(tDeque * D){ void *arr = NULL; int i; tNodo * aux = D->ppio; for(i=0; i < D->cant; i++){ arr = aux->elem; arr++; aux=aux->

    3热度

    2回答

    我已经得到了一些C代码,我不能改变结构在不同的函数变化的变量。我在我的主函数中有一个名为arr的数组: int arr[4] = {1,2,3,4} 我必须在另一个函数中更改此数组的值。在主函数内部使用如下内容: change_array(arr); change_array方法在另一个.c文件中实现。我只允许在change_array函数内进行更改。 void change_array(

    0热度

    1回答

    我正在使用“void * fdata”作为其输入之一的函数。我定义了一个名为data2的结构,并且可以使用& alldata2将一个已定义的结构变量传递给该函数,其中alldata2是在data2下定义的结构变量的名称。 我的问题是如何将f(...,void * fdata,...)中的输入转换为函数f的主体中的智能指针?函数f在一个循环内,我也在循环中使用了“#pragma omp parall

    0热度

    2回答

    我有一个函数,我有2个空指针(规范的一部分),但我知道他们是char *。我想遍历char数组,所以我试图创建一些指针来遍历它们。当我这样做,我的程序无法正常工作: int foo(void const * first, void const * second) { char const * firstIt = (const char*) first; char const

    0热度

    1回答

    typedef struct abc{ int a; char b; }abc; typedef abc bkl[1]; . . . blk b; b=shmat(shmid, NULL, 0); //This error that (Void *) to blk //But a

    0热度

    3回答

    这里是我的代码: #include <iostream> using namespace std; int main() { void *x; int arr[10]; x = arr; *x = 23; //This is where I get the error } 正如你所看到的,代码很简单。它只是创建一个void指针x,指向数组'ar

    13热度

    3回答

    我听说指针应先转换为void,以确保在不同的平台价值的一致性,应使用%p格式说明。为什么这个问题和问题到底是什么? int x=100; int *pi=&x; printf("value of pi is: %p",(void*)pi);

    9热度

    2回答

    我写和从存储器映射寄存器读取,像这样使用“无效*”的指针: //READ return *((volatile uint32_t *) (map + offset)); //WRITE *((volatile uint32_t *) (map + offset)) = value; 但是编译器给了我这样的警告: warning: pointer of type ‘void *’ use

    1热度

    1回答

    int bar(const size_t value) { char *d = (char*) value; *d = 'B'; } int main() { char bar = 'A'; bar((size_t)&d); } 是使用size_t模拟空指针类型的法律?为什么? 它有什么好处/缺点?

    0热度

    1回答

    我有基类这样的: class Test { public: virtual void* getValue() {} }; 然后,我要创建几个派生类的实现getValue方法(它们将转换其地址为void *后返回不同类型的变量): class TestA : public Test { private: int value; public: TestA (