C array Test

Source: Internet
Author: User

Today, we tested the array Address Transfer Method in vc6 and found that in the main function, the address pointed to by the array name is the same as the address of every 0 element in the array, however, when an array is passed to the called function, the parameter of the called function receives the address of the real parameter in the form of a pointer.

BelowProgramWhen you run the program for the first time, you can view the address assigned to the array by the system and then change the program;

2: change the "1245044" next to printf ("4: \ t1231644 = % s \ n", 1245044); the address assigned to your array by your system, run the command again.

1: Change // # define debug to # define debug.

 

# Include <stdio. h>
# Include <string. h>
// # Define debug

 

Int arrayaddress (char caarray [])
{
Printf ("2: \ t & caarray = % d \ tcaarray = % d \ n", & caarray, caarray );
Return 0;
}

 

Int main (void)
{
Char array [10] = "hello ";

Printf ("1: \ t & array = % d \ tarray = % d \ n", & array, array );
Arrayaddress (array );
Printf ("3: \ t & array = % d \ tarray = % d \ n", & array, array );
# Ifdef debug
Printf ("4: \ t1231644 ==% s \ n", 1245044 );
# Endif
Return 0;
}

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.