null语句是空指针吗? [英] Is a null statement a null pointer?
本文介绍了null语句是空指针吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是一个null语句空指针吗?
我尝试过:
是空语句空指针?
解决方案
否。
空指针是指将变量声明为指向某个东西的指针(例如int或double),然后尝试使用它而不将其指向有效的memopry位置。
如果你这样做可以:
int i = 666 ;
int * pi =& i;
printf( %d \ n,* pi);但是如果你这样做的话就不会这样:
int i = 666 跨度>;
int * pi;
printf( %d \ n,* pi);因为
pi
永远不会给出一个有效的整数指向。
空语句就是你不想要一个正文以你的循环为例,然后用分号终止它:
而(* pc!= ' \ 0');包含空语句,就像这样:
for (i = 0 ; i< 10 ;)
{
i = func(i);
}
Nope。
空指针描述 [ ^ ]。
null语句
是一个完全不同的野兽。你可以在这里找到它的描述:声明 - cppreference.com [ ^ ](参见'表达式语句'部分)。
is a null statement a null pointer?
What I have tried:
is a null statement a null pointer?
解决方案
No.
A null pointer is when you declare a variable as a pointer-to-something (such as an int, or a double for example) and then try to use it without "pointing it" at a valid memopry location.
It's OK if you do this:
int i = 666; int *pi = &i; printf("%d\n", *pi);But not if you do this:
int i = 666; int *pi; printf("%d\n", *pi);Since
pi
is never given a valid integer to "point at".
A null statement is when you don't want a body to your loop for example, and just terminate it with a semicolon:
while(*pc != '\0');Contains a null statement, as does this:
for (i = 0; i < 10; ) { i = func(i); }
Nope.
Null pointer description[^].
Thenull statement
is a completely different beast. you may find its description here: Statements - cppreference.com[^] (see the 'Expression statements' section).
这篇关于null语句是空指针吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文