git+ code cloud; Define the function fun and access the array inside the fun.

Source: Internet
Author: User

1. Download the English Dictionary of Computer terminology

   I'm under the European dictionary.

2. Registered Code Cloud GITOSC account

wcy947

3. Code

/*define an array containing 10 integers and initialize it, define a pointer variable p,p point to array A, define the function fun, require access to the array within the fun, and print the values of each element in the group, requiring that the number in the fun function not appear*/#include<stdio.h>intMain () {intarr[Ten] = {1,2,3,4,5,6,7,8,9,Ten}; int*p; P= arr;//Pointer to the first address of the array        intm =Ten;//defining global Variables M    intFunint*p,intm);//declaring functionsFun (p,m);//calling Functions}intFunint*p,intm) {//defining a fun function parameter is a pointer and shaping variable    inti;  for(i=0; i<m;i++) {//loop output, M is a global variableprintf"%d\n", *p+i); /*printf ("%d", *p); The second for the output *p+=1; */}}                                       

4. Running Results

1
2
3
4
5
6
7
8
9
10

--------------------------------
Process exited after 0.4907 seconds with return value 10
Please press any key to continue ...

5. Summary:

1) at the beginning of the fun function to change the for loop condition to <=9, but feel not special low so defined global variables;

2) There are fewer problems, programming a bit of thinking, *p+i the position of a thought for a while, feeling or unfamiliar;

3) git that thing is disgusting, and for a long time, (still not very clear);

4) A lot of places programming more ideas will have.

git+ code cloud; Define the function fun and access the array inside the fun.

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.