Re: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-05-29 18:43:35
|
You are using mighty big integers :-)
A 32-byte unsigned integer would store numbers up to 1*10^77
/Per W
On Thu, 29 May 2003, Avik Ghose wrote:
> Hi Andre,
> you are right, there's probably no third way out. Now I prefer to use the=
first one due to two reasons.
> 1> Being textual subsitution, the #define macro does not use up memory si=
ze whereas an integer uses up 32 bytes, though that is negligent for most p=
urposes.
> 2> The more important being that apart from compiler systems that support=
C++ along with C, the interpretation of const by the compilers around is a=
bit non-standard. Like in the Cygwin gcc complier assigment to const varia=
bles result only in a warning at compile time and program runs fine, and pr=
ints out 20!!!.
> #include <stdio.h>
> int main()
> {
> const int i =3D 10;
> i=3D20;
> printf("%d\n",i);
> return 0;
> }/*main*/
> So well although I cannot remember of a third way to do it right now, obv=
iously the first approach is better.
>
>
>
>
> Andr=E9_Mac=E1rio_Barros <and...@su...> wrote:
> Dear Users,
>
> For the sake of flexibility, I think we only have two ways to iniciatize
> a
> size of an array:
> 1) via #define:
> #define MAX 10
> ...
> int vect[MAX];
> ...
>
> 2) via cont variable:
> const int size=3D10;
> ...
> int vetc[size];
> ...
>
> So, in both ways, everytime if I need to change the size of the arrays, i=
t=B4s
> only necessary to change 10 to the other value.
>
> -->My questions:
> 1) Is there more ways to to this?
> 2) For theese two ways presented here, when use one and when use the othe=
r?
> Explaining a little more what I need to know: in a "good programming
> technique"
> point of view, what of theese two is the preferred of the programmers
> (please
> don=B4t answer "pointers" ...lol).
>
> Regards
> Andr=E9
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: eBay
> Get office equipment for less on eBay!
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> Thanx and Regards
> Avik Ghose
> Catch all the cricket action. Download Yahoo! Score tracker
|