I am also impressed with this outstanding effort on the part of Samuel and
Dave.
As an aside, I thought the dimensions of arrays in C and C++ had to be
determined at compile time, but apparently I was wrong, as this issue
demonstrates.
Variable-sized arrays also work in C++, at least with gcc 4.3. The following
compiles and runs. Based on a quick search, though, I couldn't find any
mention of it in K&R (2nd ed.), or any of the other books in my collection.
#include<iostream>
using namespace std;
int f(int x) {
int a[x];
for (int i = 0; i < x; i++)
a[i] = i*i;
for (int i = 0; i < x; i++)
cout << i << '\t' << a[i] << endl;
}
int main() {
int x;
cin >> x;
f(x);
}
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty