Ios-c Language Exercises 02

Source: Internet
Author: User

main.c//C language-pointer////Created by CGQ on 15/4/9.//Copyright (c) 2015 CGQ.    All rights reserved.//#include <stdio.h>//Direct reference to void Test () {//through the variable name A to find the address in memory, and then put 10 in 2 in the form of variable a storage control int A;    A = 10; Variable address store content//A-ffc1 0000 1010}//Indirect reference void Test2 () {///to store the address of variable A in another variable, and then through variable b    The value of the variable A is indirectly read and written by the reference variable A, char A; Char *b;    Here the *b just declares that this is a pointer,//Let pointer variable b point to variable a b = &a;          *b = 10;//here *b represents access to the storage space stored in B//variable address stored content//a ffc1 0000 1010 (*B)//b        FFC2 ffc1 printf ("a=%d\n", a);    A = 11; printf ("A =%d\n after assignment", *b);    The *b represents the value stored by the variable a}//the pointer is using void swap (int *a1,int *a2)//By value passing and by reference, passing by value does not modify the size of the original value {//Interchange A1 and A2 value int temp;    temp = *A1;    *A1 = *A2; *a2= temp;}    The addition and subtraction operation results of A and B are also obtained, similar to outvoid jiaandjian (int a,int b,int *sum,int *minus) {*sum=a+b; *minus = a-B;}    int main (int argc, const char * argv[]) {//Insert code here ... int a = 10;    int B = 20; SWAP (&AMP;A,&AMP;B);    printf ("a=%d\nb=%d\n", A, b);    int sum;    int minus;    Jiaandjian (A,b,&sum,&minus);    printf ("a+b=%d\na-b=%d\n", Sum,minus); return 0;}

Ios-c Language Exercises 02

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.