[ create a new paste ] login | about

Link: http://codepad.org/Kvq2PfNx    [ raw code | output | fork ]

C++, pasted on Sep 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

using namespace std;

int main()
{
	// Static binding.
	int size = 0;

	cout << "Enter size of array:" << endl;
	cin >> size;

	int array[size];

	int array_length = sizeof(array) / sizeof(int);
	cout << "Number of elements in array: " << array_length << endl;

	return 0;
}


Output:
1
2
3
In function 'int main()':
Line 13: error: ISO C++ forbids variable-size array 'array'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: