Hi'.
Today, I'm facing a weird bug with string. I've a function called GenerateRandomString which is generating a random string. It's working fine. You will what is the problem :
So.. How can solve this bug and how can be possible that happens ?
Код:
[12:24:01] GenerateRandomString, string (65) START is
[12:24:01] Putting i = 0
[12:24:01] String is now i
[12:24:01] -----------------
[12:24:01] Putting i = 1
[12:24:01] String is now i,
[12:24:01] -----------------
[12:24:01] Putting i = 2
[12:24:01] String is now i,8
[12:24:01] -----------------
[12:24:01] Putting i = 3
[12:24:01] String is now i,8{
[12:24:01] -----------------
[12:24:01] Putting i = 4
[12:24:01] String is now i,8{x
[12:24:01] -----------------
[12:24:01] Putting i = 5
[12:24:01] String is now i,8{x6
[12:24:01] -----------------
[12:24:01] Putting i = 6
[12:24:01] String is now i,8{x6t
[12:24:01] -----------------
[12:24:01] Putting i = 7
[12:24:01] String is now i,8{x6t9
[12:24:01] -----------------
[12:24:01] Putting i = 8
[12:24:01] String is now i,8{x6t9{
[12:24:01] -----------------
[12:24:01] Putting i = 9
[12:24:01] String is now i,8{x6t9{n
[12:24:01] -----------------
[12:24:01] Putting i = 10
[12:24:01] String is now i,8{x6t9{n$
[12:24:01] -----------------
[12:24:01] Putting i = 11
[12:24:01] String is now i,8{x6t9{n$u
[12:24:01] -----------------
[12:24:01] Putting i = 12
[12:24:01] String is now i,8{x6t9{n$un
[12:24:01] -----------------
[12:24:01] Putting i = 13
[12:24:01] String is now i,8{x6t9{n$un/
[12:24:01] -----------------
[12:24:01] Putting i = 14
[12:24:01] String is now i,8{x6t9{n$un/p
[12:24:01] -----------------
[12:24:01] Putting i = 15
[12:24:01] String is now i,8{x6t9{n$un/pn
[12:24:01] -----------------
[12:24:01] Putting i = 16
[12:24:01] String is now i,8{x6t9{n$un/pnx
[12:24:01] -----------------
[12:24:01] Putting i = 17
[12:24:01] String is now i,8{x6t9{n$un/pnx3
[12:24:01] -----------------
[12:24:01] Putting i = 18
[12:24:01] String is now i,8{x6t9{n$un/pnx3p
[12:24:01] -----------------
[12:24:01] Putting i = 19
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=
[12:24:01] -----------------
[12:24:01] Putting i = 20
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-
[12:24:01] -----------------
[12:24:01] Putting i = 21
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.
[12:24:01] -----------------
[12:24:01] Putting i = 22
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`
[12:24:01] -----------------
[12:24:01] Putting i = 23
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*
[12:24:01] -----------------
[12:24:01] Putting i = 24
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6
[12:24:01] -----------------
[12:24:01] Putting i = 25
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r
[12:24:01] -----------------
[12:24:01] Putting i = 26
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"
[12:24:01] -----------------
[12:24:01] Putting i = 27
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1
[12:24:01] -----------------
[12:24:01] Putting i = 28
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%
[12:24:01] -----------------
[12:24:01] Putting i = 29
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=
[12:24:01] -----------------
[12:24:01] Putting i = 30
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3
[12:24:01] -----------------
[12:24:01] Putting i = 31
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$
[12:24:01] -----------------
[12:24:01] Putting i = 32
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k
[12:24:01] -----------------
[12:24:01] Putting i = 33
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!
[12:24:01] -----------------
[12:24:01] Putting i = 34
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8
[12:24:01] -----------------
[12:24:01] Putting i = 35
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z
[12:24:01] -----------------
[12:24:01] Putting i = 36
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/
[12:24:01] -----------------
[12:24:01] Putting i = 37
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2
[12:24:01] -----------------
[12:24:01] Putting i = 38
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*
[12:24:01] -----------------
[12:24:01] Putting i = 39
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/
[12:24:01] -----------------
[12:24:01] Putting i = 40
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/a
[12:24:01] -----------------
[12:24:01] Putting i = 41
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af
[12:24:01] -----------------
[12:24:01] Putting i = 42
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}
[12:24:01] -----------------
[12:24:01] Putting i = 43
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{
[12:24:01] -----------------
[12:24:01] Putting i = 44
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k
[12:24:01] -----------------
[12:24:01] Putting i = 45
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,
[12:24:01] -----------------
[12:24:01] Putting i = 46
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(
[12:24:01] -----------------
[12:24:01] Putting i = 47
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*
[12:24:01] -----------------
[12:24:01] Putting i = 48
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\
[12:24:01] -----------------
[12:24:01] Putting i = 49
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<
[12:24:01] -----------------
[12:24:01] Putting i = 50
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<q
[12:24:01] -----------------
[12:24:01] Putting i = 51
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qe
[12:24:01] -----------------
[12:24:01] Putting i = 52
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu
[12:24:01] -----------------
[12:24:01] Putting i = 53
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5
[12:24:01] -----------------
[12:24:01] Putting i = 54
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[
[12:24:01] -----------------
[12:24:01] Putting i = 55
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-
[12:24:01] -----------------
[12:24:01] Putting i = 56
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;
[12:24:01] -----------------
[12:24:01] Putting i = 57
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;4
[12:24:01] -----------------
[12:24:01] Putting i = 58
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40
[12:24:01] -----------------
[12:24:01] Putting i = 59
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t
[12:24:01] -----------------
[12:24:01] Putting i = 60
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t7
[12:24:01] -----------------
[12:24:01] Putting i = 61
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t78
[12:24:01] -----------------
[12:24:01] Putting i = 62
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t78d
[12:24:01] -----------------
[12:24:01] Putting i = 63
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t78ds
[12:24:01] -----------------
[12:24:01] Putting i = 64
[12:24:01] String is now i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t78dslb4b5c<e*&{k|rop\-6*zw*k/=l(Q/fz=]zo`xnQp(j4rbQj3>g&"q1"-,]jqp=jx'(i'>>q*rywu1,p9x0]/l|kQ802i>yz[y{i\[i7|/qptg[xpQ%02-1/uelc/m^#&l^”Ёь
[12:24:01] -----------------
[12:24:01] GenerateRandomString, string (65) END is i,8{x6t9{n$un/pnx3p=-.`*6r"1%=3$k!8z/2*/af}{k,(*\<qeu5[-;40t78dslb4b5c<e*&{k|rop\-6*zw*k/=l(Q/fz=]zo`xnQp(j4rbQj3>g&"q1"-,]jqp=jx'(i'>>q*rywu1,p9x0]/l|kQ802i>yz[y{i\[i7|/qptg[xpQ%02-1/uelc/m^#&l^”Ёь
What you see is the string from your given start str2 until the first '\0' character
How a string with length of 20 characters can store longer than 20? The null character isn't automatic when you reach the max length of a string?
using sizeof operator in this case is pointless. They are replaced by cell value on compile time and won't work on run time.Also if you don't mind show the definition of that function.