that wont work under any true c++ compiler because arrays such as that must be declared with a constant size. VS .NET will not allow it.
Example:
Quote:
<kathgar> #include <iostream>
<kathgar> #include <string>
<kathgar> using namespace std;
<kathgar> int main()
<kathgar> {
<kathgar> int b;
<kathgar> cin >> b;
<kathgar> char buffer[b];
<kathgar> for(int x = 0; x < b; x++)
<kathgar> buffer[x] = 'A';
<kathgar> for(int x = 0; x < b; x++)
<kathgar> cout << buffer[x];
<kathgar> cout << ' ';
<kathgar> cout << sizeof(buffer) << endl;
<kathgar> return 0;
<kathgar> }
<kathgar> kathgar@enigma-interactive:~$ g++ -o buffer buffer.cpp
<kathgar> kathgar@enigma-interactive:~$
|
compiled fine with a standard c compiler, but not with a true C++ compiler:
Code:
c:\test\blah.cpp(8): error C2057: expected constant expression
c:\test\blah.cpp(8): error C2466: cannot allocate an array of constant size 0
c:\test\blah.cpp(8): error C2133: 'buffer' : unknown size
c:\test\blah.cpp(14): error C2070: 'char []': illegal sizeof operand
(Same program in VS)