Simple understanding of "!"

Simple understanding of "!"

I saw a code today, there is such a sentence:

pListHead *pListHead,*pToBeDeleted;
if(!pListHead||!pToBeDeleted)

I have never understood, this! The mode of the + pointer indicates that the pointer is not initialized, or the pointer is empty.
I did two experiments, the code is as follows.

int *p;
if(!p){
    cout<<"true";
}

This is a pointer without initialization, and the result is directly displayed.

int *p=new intif(!p){
    cout<<"true";
}
 Can run, no executionifcontent.

This indicates that the pointer P as long as initialization allocation memory space,! P is false.

int *p=nullptrif(!p){
    cout<<"true";
}
 print:true

This shows that for non-symbols "!", Only pointers are TRUE.
Then I did experiment with the variable INT.

int i
if(!i){
    cout<<"true";
}
 Compile Error 

This is not good, as long as it is not initialized, it is not possible to perform non-judgment.

int i=5if(i){
    cout<<"true";
}
print:true

Only in this way can be compiled, so for non-pointer variables, as long as it initializes the TRUE in IF.

Intelligent Recommendation

Exception in thread &amp;quot;AWT-EventQueue-0&amp;quot; java.lang.NullPointerException

An exception occurred when adding a mouse listener events awt Swing project Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException     at day02.LoginFrame$MyAct...

Spring Security There is no PasswordEncoder mapped for the id &amp;quot;null&amp;quot;

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"       at org.springframework.security.crypto.password.DelegatingPasswordEncoder$Unmapp...

django.template.exceptions.TemplateSyntaxError: '&amp;quot;myfilter&amp;quot;' is not a registered tag libra

Error may: 1. Create a new file in your templatetags app directory folder is defined as the package did not create __init__.py 2. issue written procedures Create a file in templatetags myfilter.py htm...

IDA 7.0 Python import &amp;quot;site&amp;quot; failed

The pit of my relatively long time, in order to prevent other people into the pit, on the timely write a blog to tell the others, in line withKnowledge and technology sharing principle. Because these ...

Exception in thread &amp;quot;main&amp;quot; java.lang.ExceptionInInitializerError

Exception in thread "main" java.lang.ExceptionInInitializerError. Today, the above error prompt abnormal main thread "Properties" when writing programs with DBHelper As shown below...

More Recommendation

Exception in thread &amp;quot;main&amp;quot; java.lang.NoSuchMethodError:

1. The following error appears in the maven-jstorm project: 2. The reason is: the jar package required by jstrom is not installed Solution: downloadjstormSource package download link: https://github.c...

header(&amp;quot;content:application/json;chartset=uft-8&amp;quot;)

demand Get content from the database and convert it to JSON format tool The Postman tool is used here as a verification of the PHP file interface (API) Code snippet 1(Without using header) First look ...

ScrollView’s handy trick--android:fillViewport=&amp;quot;true&amp;quot;

ScrollView is one of Android’s most commonly used widget and is also one of the easiest to use. When something is too big to fit on screen, drop it inside a ScrollView and you&rsq...

nginx: [emerg] unknown directive &amp;quot;sub_filter&amp;quot;

Question: Nginx's content replacement function,Integrate third-party replacement modules: ngx_http_substitutions_filter_module reports an error: Solution: Confirm that the configuration parameters con...

nginx:[emerg]unknown directive &amp;quot;ssl&amp;quot;

Restart Nginx, if... In centos, the following error occurred when configuring nginx's https. nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:102 Go to the unzipped...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top