corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » can anyone help with some C++ stuff???


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author can anyone help with some C++ stuff???
SteveW
Member

Registered: 15th Jul 02
Location: Up in the clouds
User status: Offline
27th Aug 03 at 17:04   View User's Profile U2U Member Reply With Quote

OK heres the problem:

What 3 things need to be written to declare an array???

What 2 things need to be written to access an element of an array???

Cheers peeps.

Steve
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 17:29   View User's Profile U2U Member Reply With Quote

Declare the array arrays size and the type of elements. All elements must be the same type. Write the element type name, the name of the array variable, then the size enclosed in square brackets ("[]").

int scores[100]; --- array of 100 ints, scores[0] to scores[99]
char name[40]; --- array of 40 chars, name[0] to name[39]


You need three pieces of information to gain access to an array element:

1. The starting address of the array or base address.

2. The array element number or array index you wish to access.

3. The data type size, in bytes, of the data type stored in the array. The size of the data type, along with the index, will be used to calculate an offset into the array from the address of the first element using the following formula:

address of array element = base address + (data type size * array index)

CORSA NUT
Member

Registered: 3rd Aug 01
Location: Wirral
User status: Offline
27th Aug 03 at 17:34   View User's Profile U2U Member Reply With Quote

WTF!!!!!
SteveW
Member

Registered: 15th Jul 02
Location: Up in the clouds
User status: Offline
27th Aug 03 at 17:45   View User's Profile U2U Member Reply With Quote

SXI07 - your a life saver, just found all that on a site myself actually. Well done, spot on matey.

Stay online for a bit, need some other bits answered as well

Steve
SteveW
Member

Registered: 15th Jul 02
Location: Up in the clouds
User status: Offline
27th Aug 03 at 17:47   View User's Profile U2U Member Reply With Quote

Here you are try these:

What are the allowable index values for the array MARKS???

What is necessary to initialise all elements of the array to zero???

Cheers buddy

Steve
Adam-D
Member

Registered: 11th May 02
Location: Cheshire
User status: Offline
27th Aug 03 at 17:48   View User's Profile U2U Member Reply With Quote

fuvkin hate c++
Ben
Banned

Registered: 12th Jan 03
Location: West Yorkshire
User status: Offline
27th Aug 03 at 18:03   View User's Profile U2U Member Reply With Quote

what is it
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
27th Aug 03 at 18:04   View Garage View User's Profile U2U Member Reply With Quote

1) A definition of the array MARKS might help answer the question? If you mean the range of values, then it's just ( array size - 1 ) i.e. int marks[100] would have values 0 - 99.

2) To initialise everything to zero, just do

int marks[100] = {0};

[Edited on 27-08-2003 by Tim]
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 18:08   View User's Profile U2U Member Reply With Quote

lol, you got me on the first one! but if you want to initialise an array to all zeros, initialise it with single zeros:

char cArray[100]={0};

m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 18:08   View User's Profile U2U Member Reply With Quote

bastard, tim replied quicker
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 18:09   View User's Profile U2U Member Reply With Quote

tim check your mails
neiliosxi
Member

Registered: 17th Dec 02
Location: Teesside (NE)Drives: Megane R26
User status: Offline
27th Aug 03 at 18:35   View User's Profile U2U Member Reply With Quote

I had to learn all this at uni, 1st year on electrical engineering degree, its a nightmare if u have never heard of C++!!!
SteveW
Member

Registered: 15th Jul 02
Location: Up in the clouds
User status: Offline
27th Aug 03 at 18:36   View User's Profile U2U Member Reply With Quote

Great, but why would it be necessary to do this??

Steve
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 19:05   View User's Profile U2U Member Reply With Quote

lol sorry, forgot your question: a loop is used to initialise the whole array to zero, thus even if the array size increases, the main loop code still remains the same. All that would change is the constant iSIZE.


Richie
Member

Registered: 3rd Dec 02
Location: Newport, Wales
User status: Offline
27th Aug 03 at 19:08   View User's Profile U2U Member Reply With Quote

Steven stop cheating
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 19:10   View User's Profile U2U Member Reply With Quote

lol steve are you doing course work or something? right, thats it.. no more help for you
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
27th Aug 03 at 19:15   View Garage View User's Profile U2U Member Reply With Quote

No he's playing with C++ for fun
m-dot
Member

Registered: 17th Aug 03
Location: Warrington
User status: Offline
27th Aug 03 at 19:20   View User's Profile U2U Member Reply With Quote

he might be
SteveW
Member

Registered: 15th Jul 02
Location: Up in the clouds
User status: Offline
27th Aug 03 at 20:22   View User's Profile U2U Member Reply With Quote

you got me

Cant get my head round this shite

Steve
corb
Member

Registered: 24th Apr 02
Location: Calgary, Alberta, Canada
User status: Offline
27th Aug 03 at 20:54   View User's Profile U2U Member Reply With Quote

What is it?
corb
Member

Registered: 24th Apr 02
Location: Calgary, Alberta, Canada
User status: Offline
27th Aug 03 at 20:55   View User's Profile U2U Member Reply With Quote

And have u got any pics of Hels install anywhere?

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
PVD workers.. sinkyboy General Chat 11 1287
8th Jul 03 at 21:27
by vibrio
 
cold air feed koolkorsa Help Zone, Modification and ICE Advice 13 1292
5th Nov 03 at 11:28
by The Guru
 
ebc discs and greenstuff pads corsa-c Shamus Help Zone, Modification and ICE Advice 12 1087
5th May 04 at 09:47
by chewbaccaman
 
Where to get? Gaz General Chat 34 2121
7th Oct 06 at 22:59
by Adam_B
 
wher to get stuff from alex sport 16v General Chat 7 684
30th Mar 08 at 17:37
by AK
 

Corsa Sport » Message Board » Off Day » Geek Day » can anyone help with some C++ stuff??? 28 database queries in 0.0401461 seconds