Use of command line parameters, use of goto labels, and local variable declaration in the For Loop

Source: Internet
Author: User

/*
* Test command line parameters

*/
# Include <iostream>
Using namespace STD;

Int main (INT argc, char * argv []) {
 
Cout <argv [0] <Endl; // The first parameter is the applicationProgramName
Cout <argc <Endl;
 
}

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

/*

* Use the Goto tag

*/

# Include <iostream>
Using namespace STD;

Int main (){
 
Int I = 4;
Flag:
Cout <I <Endl;
If (I! = 0 ){
I = 0;
Goto flag;
}
Return 0;
}

 

~~~~~~~~~~~~~~~ Strange local variables are not initialized ~~~~~~~~~~~~~~~~ ·

 

# Include <iostream>
Using namespace STD;

Int main (){
 
Int J;
For (INT I = 0, j = 0; I <5; I ++, J ++ );
 
Cout <j <Endl;

}

Here, if int I = 0 is used in the for loop, the compiler considers that J is only a local variable. The output J value is also a random number.

The reason is that the statement int I = 0, j = 0 is interpreted as declaring two local variables I, J at the same time, and assigning the initial value.

J declared before the for loop is blocked.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.