Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random number
#15
Don't use pointer-based arrays of str type, because it is too difficult, because you must not only move memory but also properly clear str elements. This is example:

Code:
Copy      Help
;create array
str* p._new(10)
int i
for i 0 p._len
,p[i].from("line" i)

;remove element 3
int rem=3
int nelementstomove=p._len-rem-1
if(nelementstomove)
,p[rem].all
,memmove &p[rem] &p[rem+1] nelementstomove*sizeof(str)
,p[p._len-1].lpstr=0
p._resize(p._len-1)

;results
out
for i 0 p._len
,out p[i]

p._delete



There are 7 lines of code to remove str element. Unless you put it in a function.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)