mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
30 lines
732 B
C++
30 lines
732 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2016-2021 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** staticsize.cxx : sizeof and arrays
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cout;
|
|
|
|
#include <vector>
|
|
using std::vector;
|
|
|
|
int main() {
|
|
|
|
//codesnippet sizeofarray
|
|
int a1[10];
|
|
cout << "static: " << sizeof(a1) << '\n';
|
|
int *a2 = (int*) malloc( 10*sizeof(int) );
|
|
cout << "malloc: " << sizeof(a2) << '\n';
|
|
vector<int> a3(10);
|
|
cout << "vector: " << sizeof(a3) << '\n';
|
|
//codesnippet end
|
|
|
|
return 0;
|
|
}
|