C language pointer and pointer array as the formal parameter of main function

Source: Internet
Author: User

A main function with no formal parameters is generally written as:
int main () or int main (void)
Indicates that the Mian function has no arguments, and that no arguments are required to invoke the Mian function.

And the form of the main function's physical parameter:

int main (int argc, char** argv)  

int main (int argc, char *argv[])  

I understand these two ways, the first of which is the pointer, the pointer to the variable, the pointer is an address, so *ARGV is a **argv. The second type of *argv[] is an array of pointers, because [] has a higher precedence than *, so argv[] is an array, and the array name actually represents the first address, or an address. So there is no difference between the two methods.
Write such a test code under the VS2010

int main (int argc, char * * argv)  
{  
    Iplimage *img = Cvloadimage (argv[1), 1);  
    Cvnamedwindow ("initial", 1);  
    Cvshowimage ("initial", IMG); 
    Cvdestroyallwindows ();  
    Cvreleaseimage (&img);
    return 0;

Where Argv[1] represents the fact that the second argument in the command-line argument is interpreted, and in this case he is a picture path, because the first parameter is the executable file name given by the operating system.
Under the compiler, the property-debug-command arguments are written to the picture path

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.