int (*a)[5];
Run Code Online (Sandbox Code Playgroud)
我们如何初始化一个指向上面显示的5个整数数组的指针.
以下表达是否正确?
int (*a)[3]={11,2,3,5,6};
Run Code Online (Sandbox Code Playgroud) 什么是Linux中的设备树?设备树的优点和缺点是什么?
如果有人详细了解设备树,请帮助回答上述问题.
我写了一个C程序如下:
int *a; /* pointer variable declaration */
int b; /* actual variable declaration */
*a=11;
a=&b;/* store address of b in pointer variable*/
Run Code Online (Sandbox Code Playgroud)
它在运行程序时出现分段错误.
我更改了代码如下:
int *a; /* pointer variable declaration */
int b; /* actual variable declaration */
a=&b;/* store address of b in pointer variable*/
*a=11;
Run Code Online (Sandbox Code Playgroud)
现在它工作正常.
如果有人知道请解释为什么它在CASE 1中给出了分段错误.
在3.9.6中找不到VM_RESERVED常量和nopage方法(in vm_operations_struct).它们在3.9.6中的替代品是什么?
int main()
{
int *p;
p = malloc(5 * sizeof(int));
p =(int[5]) {11,12,13,14,15};
printf("[%d] [%d] [%d] [%d] [%d] \n",p[0],p[1],p[2],p[3],p[4]);
printf("[%lu] [%lu] [%lu] [%lu]\n",sizeof(&p[0]),sizeof(&p[1]),sizeof(&p[2]),sizeof(p));
printf("[%p] [%p] [%p] \n",&p[0],&p[1],p);
free(p);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在运行exe时,我得到以下内容
[11] [12] [13] [14] [15]
[8] [8] [8] [8]
[0x7fff48ee93e0] [0x7fff48ee93e4] [0x7fff48ee93e0]
*** glibc detected *** ./a.out: double free or corruption (out): 0x00007fff48ee93e0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7fcce0856b96]
./a.out[0x40068a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fcce07f976d]
./a.out[0x4004c9]
======= Memory map: ========
00400000-00401000 r-xp 00000000 08:05 408246 /home/user1/Desktop/c/a.out
00600000-00601000 r--p 00000000 08:05 408246 /home/user1/Desktop/c/a.out
00601000-00602000 …Run Code Online (Sandbox Code Playgroud)