Restored from previous forum. Originally posted by talun.
Dear all,
I was not able to found in this Forum and in the PureBasic help, informations related to the use of square brackets in PureBasic programs.
Can anyone help me?
Thanks a lot
Sergio
square brackets
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
cya,
...Danilo
(registered PureBasic user)
Code: Select all
Structure mytest
byte.b[5]
EndStructure
x.mytest
x\byte[0] = 'H'
x\byte[1] = 'E'
x\byte[2] = 'L'
x\byte[3] = 'L'
x\byte[4] = 'O'
x\byte[5] = 0
MessageRequester("",PeekS(x),0)...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
In fact, there is a subtility. in structure, byte.b[5] actually allocate 5 elements from 0 to 4. It's not like nomal arrays, which allocate from 0 to 5. You may ask 'Why ?'.. It's because C langage use this def, and as PB support all the API, it had to conform to C to convert all the headers, which make huge use of such arrays.
Fred - AlphaSND
In fact, there is a subtility. in structure, byte.b[5] actually allocate 5 elements from 0 to 4. It's not like nomal arrays, which allocate from 0 to 5. You may ask 'Why ?'.. It's because C langage use this def, and as PB support all the API, it had to conform to C to convert all the headers, which make huge use of such arrays.
Fred - AlphaSND
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by talun.
Hi Danilo and Fred,
many thanks for your help.
Therefore if I don't have misunderstood, the square brackets notation allows to access data elements located at specific address in memory by using a kind of indexed pointers. It's wrong?
bye
Sergio
Hi Danilo and Fred,
many thanks for your help.
Therefore if I don't have misunderstood, the square brackets notation allows to access data elements located at specific address in memory by using a kind of indexed pointers. It's wrong?
bye
Sergio
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm