An array of problems passed as arguments

Source: Internet
Author: User

/* ============================================================================ name:testarray.c AUTHOR:LF Version:Copyright:Your Copyright Notice Description: Array is passed as an argument when an array is passed as a parameter because the copy of the array is a resource-intensive 1. To avoid In this case, the C language compiler passes an array of pointers when passing an array 2 c the array name represents the first address of the array, but after the array parameter is received, it acts on the original array. This question is a bit special, for the record, follow-up. ============================================================================ * * #include <stdio.h> #include <stdlib.h>int Main (void) {//occupies a memory size of 20 bytes int array[5]={1,2,3,4,5};p rintf ("main int array[5] size=%d\n", sizeof ( Array));p rintf ("===========\n"), int i;for (i=0;i<5;i++) {printf ("First array[%d]=%d\n", I,array[i]);} printf ("===========\n");//pass the array as a parameter to the other function Testarray (array); for (i = 0; i < 5; i++) {printf ("Second array[%d]=%d\n", I, Array[i]);} printf ("===========\n"); return exit_success;} void Testarray (int array[5]) {//Because the pass-through is just a pointer, so its size is 4 bytes of printf ("Testarray int array[5] size=%d\n", sizeof (array)); printf ("===========\n");//change the original array int i;foR (i = 0; i < 5; i++) {array[i] = Array[i] + 5;}} 

An array of problems passed as arguments

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.