Fundamentals of C + + programming 117-pointers and arrays

Source: Internet
Author: User

1 //17-pointers and arrays. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7 8 using namespacestd;9 Ten intMain () One { A     inta[]{345, $, at,7,2,856, at, the,176};  -cout << a << Endl;//Output array is also output a string of addresses, the output address is the first element of the array address. Arrays are also pointers in C + +.  -     //If array A is a pointer, you can view the value of the pointer with the same *a, which should be 345.  thecout << *a <<Endl; -     //when the pointer is an array, you can add the subtraction operation, and +1 points to the next element in the array.  -cout << * (A +1) << Endl;//the output value is -  +* (A +1) = +;//a+1 refers to the second bit of an array and modifies the value of the second bit of array A to 1000.  -cout << a[1] <<Endl; +  A     //so access to the array can be numbered not only by the array name, but also by pointers to the values in the array.  at  -     //create an array using new.  -     int* p =New int[ -];//the active application of the memory is to delete -p[0] = -; -cout << p[0] <<Endl; -  in* (P +2) = the;//modifies the value by pointer.  -cout << p[2] <<Endl; to  +     Delete[] p;//If an array is requested, you have to use delete[] to delete the array p -  the     //It is recommended to create arrays in a normal way, pointers are used with caution!  *  $     intT;Panax NotoginsengCIN >>T; -     return 0; the}

Fundamentals of C + + programming 117-pointers and 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.