#include<iostream> |
The address of a[0]: 0012FF74 |
#include<iostream> |
11 |
a holds the address of a[0].
#include<iostream> |
a b c |
a is the address of a[0].
The value of a+1 is the address of a[1].
The value of a+2 is the address of a[2].
#include<iostream> |
3.14 2.71 4.14 2.71 |
#include<iostream>
using namespace std;
int main() {
int *p;
int a[10];
int b[10] = {2,4,6,8,10,12,14,16,18,20};
int index;
// a[index] is index
for(index = 0; index < 10; index++)
a[index] = index;
p = a;
// p[index] is same as a[index]
cout << "p array is :\n";
for(index = 0; index < 10; index++) {
cout << p[index] << " ";
}
cout << endl;
// change p[index] will change a[index]
for(index = 0; index < 10; index++) {
p[index] = p[index] + 1;
}
cout << "p array is :\n";
for(index = 0; index < 10; index++) {
cout << p[index] << " ";
}
cout << endl;
cout << "a array is: \n";
for(index = 0; index < 10; index++) {
cout << a[index] << " ";
}
cout << endl;
p = b;
// p[index] is same as b[index] now
cout << "p array is :\n";
for(index = 0; index < 10; index++) {
cout << p[index] << " ";
}
cout << endl;
return 0;
}
|
p array is : 0 1 2 3 4 5 6 7 8 9 p array is : 1 2 3 4 5 6 7 8 9 10 a array is: 1 2 3 4 5 6 7 8 9 10 p array is : 2 4 6 8 10 12 14 16 18 20 |
#include<iostream> |
Cannot convert from double * to double[2] |
x is actually of type const double*. A constant can't be changed.
#include<iostream> |
#include<iostream> |
typedef?
|
p2 (an integer or a pointer) ?
#include <iostream> |
#include <iostream> |
Please enter the number of students: 5
Please enter the scores:
90.5 91.25 55 25.9 73
The scores are:
90.5 91.25 55 25.9 73
|
scores = new double[numOfStudents]:
The size of the dynamic array (numOfStudents) is given
in square bracket.int variable or other expression.int whose value is determined while the program is running.int[] someFunction(); // illegal!!!!Example:
int* someFunction(); // legal!
#include <iostream> |
Array a: |