c++ - How do you delete (or fill with specific values) a static n-dimension array? -
const int rows = 3; const int columns = 4; void fillarray(double a[rows][columns], double value); void deletearray(double a[rows][columns]); int main () { double a[rows][columns]; fillarray(a, 0); deletearray(a); }
in c++, how delete (or fill specific values) static n-dimension array?
in c++ not use arrays. use std::vector
. can use memset
or std::fill
fill array specific values. btw can use delete
on dynamically allocated arrays not on static ones.
memset( a, 0 ,rows * columns * sizeof( double )); or std::fill(&a[0][0], &a[0][0]+sizeof(a)/sizeof(double), 0);
Comments
Post a Comment