Re: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <Avi...@ne...> - 2003-05-29 21:50:51
|
Typo I meant 32 bits :-)
Per Westermark <pw...@ia...> wrote:
>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 size whereas an integer uses up 32 bytes, though that is negligent for most purposes.
>> 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 variables result only in a warning at compile time and program runs fine, and prints out 20!!!.
>> #include <stdio.h>
>> int main()
>> {
>> const int i = 10;
>> i=20;
>> printf("%d\n",i);
>> return 0;
>> }/*main*/
>> So well although I cannot remember of a third way to do it right now, obviously the first approach is better.
>>
>>
>>
>>
>> André_Macário_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=10;
>> ...
>> int vetc[size];
>> ...
>>
>> So, in both ways, everytime if I need to change the size of the arrays, it´s
>> 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 other?
>> 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´t answer "pointers" ...lol).
>>
>> Regards
>> André
>>
>>
>>
>>
>> -------------------------------------------------------
>> 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
>
>
--
Regards
---------------------------------------
Avik Ghose
Software Engineer (Real Time Group)
Rebaca
Systron Building, 3rd Floor
Plot No: J-5, Block: EP & GP
Saltlake Electronics Complex, Sector V
Kolkata: 700091
India
Phone: 91-33-2357-7177 ext 16
Fax: 91-33-2357-7178
Mobile: 91-0-9830039737
__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
Get AOL Instant Messenger 5.1 free of charge. Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
|