[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TRNSYS-users] sizeof array



Hi Jörn,

 

Sizeof() only gives you the size of the memory allocated, not the number of elements actually used by TRNSYS.

You need to look into the INFO array to determine the actual number of inputs:

 

int Ninputs = info[2];

in C or C++

 

integer Ninputs = INFO(3)

in FORTRAN.

 

The TRNSYS Programmer’s Guide (chapter 8) describes all that INFO has to offer under

8.4.3. The INFO array – Typical calling sequence

 

Werner

 

 


De : Jörn von Grabe [mailto:v.Grabe@bv.tu-muenchen.de]
Envoyé : lundi 28 juillet 2008 12:03
À : trnsys-users@engr.wisc.edu
Objet : [TRNSYS-users] sizeof array

 

dear all!

 

my type – written in c++ -  needs a dynamic number of inputs and outputs. this i implement by a cycle in the proforma. thus, the xin and xout arrays do not have a constant size anymore which can be set in the source code directly. instead, i have to determine the size of the arrays dynamically. i tried sizeof(xin/xout), this however yields the size of the bytes needed by the variabel type, but not the number of the array elements. as far as i understand, the arrays that are passed are c-arrays, not c++arrays (for c++ arrays sizeof yields the total number of bytes of the array so that the number of elements are given by sizeof(array)/sizeof(type)) . how do i get the number of elements? can c-arrays easily be converted into c++arrays (not my favourite)? are c-arrays generally 0-terminated (i can remember anymore...)? does anyone have a simple solution which i am to blind to see???

 

regards

jörn

 

 





************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************






************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************