此代码为i和&i打印不同的值,并且它们都不等于10。请解释一下这两个数字所表示的含义。
#include<stdio.h>
int main(){
int p=10;
int *i=&p;
printf("%d %d",i,&i);
}
答案 0 :(得分:0)
$(document).ready(function() {
$('#btn-search').on('click', function() {
$.ajax({
type: "GET",
url: "{{myurlapi }}",
}).done(function(result) {
var table = $('#example').DataTable({
"data": result.data,
"columns": [{
"data": "id"
},
{
"data": "name"
},
{
"data": null
}
],
"columnDefs": [{
"searchable": false,
"orderable": false,
"targets": 0
},
{
width: '3%',
targets: 0
},
{
targets: -1,
data: null,
defaultContent: '<div class="btn-group"> <button type="button" class=" btn btn-view"><span> <i class="icon-plus"></i></span> </button></div>'
},
],
"processing": true,
"retrieve": true,
"searching": false
});
table.clear().draw();
table.rows.add(result).draw();
});
});
$(document).ajaxComplete(function() {
$('#example tbody').on('click', '.btn-view', function(e) {
alert('something')
});
});
});
是i
,将用于存储integer pointer
的地址。在这种情况下,integer variable
存储在主存储器的堆栈区域中,当您打印i
时,这意味着您要打印存储&i
的地址。当您打印i
时,它表示您打印i
的值(i
的值是i
的地址,因为您已将p
分配给&p
通过此行i
)。我希望它对您有用。
答案 1 :(得分:0)
这是代码的修改版本,在printfs中带有注释。请注意,我添加了第三个printf来引用int
p
#include<stdio.h>
int main(){
int p=10;
int *i=&p;
printf("'i' = %p is the address of the int stored in variable p\n",(void *)i);
printf("'&i' = %p is the address of the pointer to an int called i\n",(void *)&i);
printf("'*i' = %d is the int that is stored at the location in i which points to p\n",*i);
}
'i' = 0x7ffee4e63abc is the address of the int stored in variable p
'&i' = 0x7ffee4e63ab0 is the address of the pointer to an int called i
'*i' = 10 is the int that is stored at the location in i which points to p