Array: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
[[category:variables]][[Category:Glossary]]
I have a problem. I searched all over the net without result:(
'''Array'''s are a set of [[variable]]s of the same type with a built in capacity
When u open hammer u got 4 screens. 1 in 3D and 3 in 2D. First it was normal but now it looks like this.[[http://users.telenet.be/downloadarea/hammer.jpg]] plz help
 
send reply here or to vancaeneghempieter@hotmail.com
An example of an array is below:
thx
 
    int lotsOfInts[100];
 
This declares an [[integer]] '''array''', with at maximum 100 members.
This is because when a compiler sees the ''100'' within the braces it knows to allocate enough memory to the '''array''' to hold 100 [[integer]]s.
 
When accessing a member of an '''array''' it is important to remember that they are numbered starting at zero.
Therefore
 
lotsOfInts[3];
 
actually refers to the 4th [[integer]] member of the '''array'''.
Strings can be created by making a [[char]]acter '''array''', as seen below.
 
char thisIsAString[5];
thisIsAString[0]='H';
thisIsAString[1]='e';
thisIsAString[2]='l';
thisIsAString[3]='l';
thisIsAString[4]='o';
 
Or this can be performed in one action as follows:
 
char thisIsAString[5] = {'H','e','l','l','o'};
 
The same style of setting up an array applies to any type of variable.
However strings are more commonly stored in a [[char]]*, a character [[pointer]].
[[pointer]]s can be used fairly similarly to '''arrays'''
 
'''Array''' members can also be accessed via [[pointer]]s.
 
Custom classes can be used in '''arrays'''.
[[Vector]]s are an alternative to '''arrays''' that allow more mathematical operations suited to manipulating various quantities related to geometry and physics, such as force [[vector]]s and normal [[vector]]s.

Revision as of 10:55, 8 February 2006

I have a problem. I searched all over the net without result:( When u open hammer u got 4 screens. 1 in 3D and 3 in 2D. First it was normal but now it looks like this.[[1]] plz help send reply here or to vancaeneghempieter@hotmail.com thx