Struct-function -- parameter & Return Value

Source: Internet
Author: User

Example:

Int main () {iplimage * src = cvloadimage ("lena.bmp", 0); iplimage * DST = myfun (SRC); cvnamedwindow ("src "); cvnamedwindow ("DST"); cvshowimage ("src", Src); cvshowimage ("DST", DST); cvwaitkey (-1); cvreleaseimage (& SRC ); cvreleaseimage (& DST); cvdestroyallwindows (); Return 0;} iplimage * myfun (iplimage * IMG) {iplimage * src = IMG; iplimage * DST = cvcreateimage (getcvsize (SRC ), 8, 1); int I, j; for (I = 0; I <Src-> height; I ++) for (j = 0; j <Src-> width; j ++) cvset2d (DST, I, j, cvget2d (SRC, I, j); Return DST ;}

There are a total of two structs with storage space (SRC in main and DST applied in myfun), and the rest are just a pointer to the address

The storage space of these two structs is released in main.

[The release of DST space in myfun cannot be in myfun, because it will be returned for display in the main function. As long as you know the address (recorded by DST in main), you can release it after it is displayed in main]

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.