variable_size_array.cpp
This commit is contained in:
36
cpp/variable_size_array.cpp
Normal file
36
cpp/variable_size_array.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
VIM: let g:lcppflags="-g -O2 -pthread"
|
||||||
|
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||||
|
VIM: let g:argv=""
|
||||||
|
*/
|
||||||
|
#include <iostream>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
void f( int n )
|
||||||
|
{
|
||||||
|
int arr[n];
|
||||||
|
int arr2[2*n];
|
||||||
|
std::cout << sizeof( arr ) << ' ' << sizeof( arr2 ) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main ( void )
|
||||||
|
{try{
|
||||||
|
|
||||||
|
f(10);
|
||||||
|
f(20);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch ( const std::exception& e )
|
||||||
|
{
|
||||||
|
std::cerr << std::endl
|
||||||
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
catch ( ... )
|
||||||
|
{
|
||||||
|
std::cerr << std::endl
|
||||||
|
<< "unknown exception." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}}
|
||||||
|
|
||||||
Reference in New Issue
Block a user