pointers

    0热度

    1回答

    这是我教科书中问题的一部分。我无法弄清楚它究竟做了什么以及它是如何做到的,所以我一直在寻求帮助。 int a = 5, b[] = {1, 2, 3, 4, 5}; int *ptr1, *ptr2; void *ptr3; ptr1 = &a; ptr2 = b; ptr3 = (int*) &ptr2; 我不明白这行 ptr3 = (int*) &ptr2; 我最好的猜测是,pt

    -1热度

    4回答

    输出必须是 Student Number: 93745; Grade Point Ave:2.9; Sex (M or F):'M'; ,但我不能让那些需要的输出,请点错误代码,并帮助解决它,谢谢! #include <stdio.h> struct student { int num; double gpa; char sex; }; void printstudent(

    1热度

    2回答

    新实例,我有这样的问题: void myFunc() { MyClass * myInstance = NULL; newInstance(myInstance); } void newInstance(MyClass * instance) { instance = new MyClass(...); } 的代码看起来工作正常,但是当从的newIn

    1热度

    3回答

    我正在写的矩阵乘法程序,以及保存代码空间我创建了一个函数make,需要一个指针到一个双指针和动态地分配给定大小的2维阵列。数组a和b初始化为[-2,2]中的随机值。但是,当我尝试在gcc上运行代码时,出现seg故障。 我通过GDB跑的代码,当我尝试设置b[0][0]随机数错误出现。当我尝试在gdb打印b[0][0],我得到的错误: Cannot access memory at address 0

    0热度

    7回答

    我目前转换Csharp的程序到Unix的C.它的运行良好,除了: 我有一个整数(秒)含有秒数,对于美学原因,我想显示前零(1-> 01等)。我制作的代码在下面,它有时会起作用,有时不起作用,具体取决于调用的位置。我怀疑问题在于指针。 char *st_str; if(secs<10) { if(secs==0) st_str = "00"; else if(secs==1)

    3热度

    3回答

    我有一个(未注释的...)源文件,我试图理解。 static const Map *gCurMap; static std::vector<Map> mapVec; 然后 auto e = mapVec.end(); auto i = mapVec.begin(); while(i!=e) { // ... const Map *map = gCurMap = &(*

    0热度

    2回答

    我有一个类: class WorkerThread { public: unsigned virtual run() { return 0; } }; 定义在头。现在,在另一个类我创建这个类型的对象: WorkerThread **workerQueue; 这实际上是对指针... OK指针,都好到现在为止。 现在,我应该怎么看这个: work

    1热度

    3回答

    因为我不是C(++)专家,所以我被编译器的一些固执难住,不想将QString转换为QString *。 我有一个函数: bool getNextMessage(int sId, QString *msg, QString *cmd) 我使用的指针,在这里,因为我不能返回多个变量(被宠坏的Perl编码器;)在C),我想在一段时间(getNextMessage(使用这个.. 。)){...}样式循

    5热度

    3回答

    此代码似乎按预期方式工作,填充使用单个指针数的数组 #include <stdio.h> #include <ctype.h> #include <stdlib.h> int main(void) { int arr[4], count = 0, i; char *p, s[32] = " \t 10, 15 \n ,20, 25 , "; p = s;

    1热度

    5回答

    我遇到了指向二维数组的指针问题。指针应指向一个可变大小的数组。 // create pointer to 2 dimensional array TimeSlot **systemMatrix; // this is a global variable 在函数中我想创建一个新的数组。 void setup(uint16_t lines, uint16_t coloumns) { /