[ASM C + +] C-language arrays

Source: Internet
Author: User

/* Fixed-length array:

can have any storage class.

Variable-length arrays:

Can only have an automatic life cycle (defined within a statement block, optimised does not have a static modifier).

The name must be a generic identifier, so a struct or union member cannot be an identifier for an array.

Reading and writing array data can be indexed and pointer-by-two methods.

*/

#include <stdio.h>inta[Ten];//with external linksStatic intb[Ten];//has a static life cycle and scopevoidParray (intCountintarr[]) {    //Indexed Access     for(intI=0; i<count; i++) {printf ("The %d is:%d \ n", I, arr[i]); }    //pointer Access     for(int*p = arr; P < arr + count; ++p) {printf ("p The value is:%d \ n", *p); }}intMainintargcChar*argv[]) {    Static intc[Ten];//static life cycle and statement block scope//int d[10]; //has self-life cycle and statement block scope    intvla[2*ARGC];//automatic life cycle, variable-length array//error:variable length Array declaration can not have ' static ' storage duration//static int e[n]; //refined life cycle, cannot be a variable length array//Error:fields must has a constant size: ' variable length array in structure ' extension'll never be supported 
    //struct S {int f[n]};//Small labels cannot be long variable array names    structSintf[Ten]; };//Small labels cannot be long variable array names//Multidimensional Arrays    extern inta2d[][5]; //int A3d[2][2][3] = {{{110,111,112},{120,121,122}},{{210,211,212},{220,221,222}}}; //int A3d[][2][3] = {{{1},{4}},{{7,8}}}; //int A3d[2][2][3] = {{1,0,0,4}, {7,8}}; //int A3d[2][2][3] = {1, [0][1][0]=4, [1][0][0]=7,8};    inta3d[2][2][3] = {{1}, [0][1]=4, [1][0]={7,8}}; //Initialize//int d[] = {n/a}; //D[0] = 1, d[1]=2, d[2]=3;    intd[Ten] = {1,2,3,[6]=6};//initializing a specific elementParray (Ten, D); return 1;} 

[ASM C + +] C-language arrays

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.