From: Jan M. <jan...@vo...> - 2008-04-01 05:32:20
|
Hello, I would like to ask if there is a possibility to get a dimesion of an arry. I have have got an array char arr[][] ={:one:, :two:, three:}, And I would like to go thru the whole arry or several members. So shuld I store the value 3 like an number of members? Or can I to found it generally. Took a look to array definition but have not found anything. Thank you. Jan Mura jan...@vo... |
From: Per W. <pw...@ia...> - 2008-04-01 05:42:35
|
No general way to find the size of an array. That is one of the reasons for the STL container classes. Anyway, if you can see the definition of the array, you can write: #define NELEM(a) (sizeof(a)/sizeof(*(a))) char arr[] = {"one","two","three"}; int arr_count = NELEM(arr); /pwm On Tue, 1 Apr 2008, Jan Mura wrote: > Hello, > > I would like to ask if there is a possibility to get a dimesion of an arry. > I have have got an array > char arr[][] ={:one:, :two:, three:}, > > And I would like to go thru the whole arry or several members. So shuld I > store the value 3 like an number of members? > Or can I to found it generally. Took a look to array definition but have not > found anything. > > Thank you. > > Jan Mura > jan...@vo... > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: <Mat...@bm...> - 2008-04-01 05:52:59
|
Try using a vector instead, they are resizable and have methods which return the size etc.. >-----Original Message----- >From: dev...@li... [mailto:dev-cpp-users- >bo...@li...] On Behalf Of Per Westermark >Sent: 01 April 2008 06:42 >To: Jan Mura >Cc: dev...@li... >Subject: Re: [Dev-C++] Arry dimensions > >No general way to find the size of an array. That is one of the reasons >for the STL container classes. > >Anyway, if you can see the definition of the array, you can write: > >#define NELEM(a) (sizeof(a)/sizeof(*(a))) > >char arr[] = {"one","two","three"}; >int arr_count = NELEM(arr); > >/pwm > >On Tue, 1 Apr 2008, Jan Mura wrote: > >> Hello, >> >> I would like to ask if there is a possibility to get a dimesion of an >arry. >> I have have got an array >> char arr[][] ={:one:, :two:, three:}, >> >> And I would like to go thru the whole arry or several members. So shuld I >> store the value 3 like an number of members? >> Or can I to found it generally. Took a look to array definition but have >not >> found anything. >> >> Thank you. >> >> Jan Mura >> jan...@vo... >> >> >> ------------------------------------------------------------------------ - >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> >http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/market plac >e >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> > > >----------------------------------------------------------------------- -- >Check out the new SourceForge.net Marketplace. >It's the best place to buy or sell services for >just about anything Open Source. >http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/market plac >e >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users This email was sent from an email account of BMW (UK) Manufacturing Limited. BMW (UK) Manufacturing Limited is a company registered in England and Wales with company number 3950868; and has its offices at Ellesfield Avenue, Bracknell, Berkshire, RG12 8TA; registered in England and Wales. The contents of this e-mail are confidential and may be privileged and subject to internal monitoring. If you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it or any part of it in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of any BMW Group Company shall be understood as neither given nor endorsed by them. |
From: Deepesh K. <dee...@gm...> - 2008-04-02 09:51:57
|
hello all, I have a question here.. How to set a float datatype's value to 2 decimal places?? and also wat code to use to set the currency value of value set in a float or double datatype??? Will it be the same as setting it to 2 dp, as in my first question??? please do reply, Thanx.. ==DK== |
From: <Mat...@bm...> - 2008-04-02 15:03:49
|
I use this function which I got from S.C Wong from code project. It will round a double to two decimal places. You need to include math.h to use it though. // rounds a double variable to nPlaces decimal places double Round(double dbVal, int nPlaces /* = 0 */) { const double dbShift = pow(10.0, nPlaces); return floor(dbVal * dbShift + 0.5) / dbShift; } Hope that helps, MT ________________________________ From: dev...@li... [mailto:dev...@li...] On Behalf Of Deepesh Kapadia Sent: 02 April 2008 10:52 To: dev...@li... Subject: Re: [Dev-C++] Arry dimensions hello all, I have a question here.. How to set a float datatype's value to 2 decimal places?? and also wat code to use to set the currency value of value set in a float or double datatype??? Will it be the same as setting it to 2 dp, as in my first question??? please do reply, Thanx.. ==DK== This email was sent from an email account of BMW (UK) Manufacturing Limited. BMW (UK) Manufacturing Limited is a company registered in England and Wales with company number 3950868; and has its offices at Ellesfield Avenue, Bracknell, Berkshire, RG12 8TA; registered in England and Wales. The contents of this e-mail are confidential and may be privileged and subject to internal monitoring. If you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it or any part of it in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of any BMW Group Company shall be understood as neither given nor endorsed by them. |