Without the prior knowledge that integers store 2 byte in C,or char store 4 byte,float reserves 'so and so bytes',...etc
Is it possible to deduce directly from a C program which datatype store what amount of free memory?
I tried this code but it was without any results.
(As array of any datatype stores consecutive memory locations I declared )
(Then I substracted the adress and printed )Code:int a[2]; char b[2]; float c[2];
The result should come 4 but it was in vain,it was showing 1 as output which is wrong.....Code:printf("For integer data type : Bytes stored = %d",(&a[1])-(&a[0]));
In case of deduction of other datatype also ,I went on with the same logic ,but the result in each case was erronious
Please help,
Refer if some shorter methods available...



3Likes
LinkBack URL
About LinkBacks





