May 28, 2011 at 11:47am UTC
i really need help on solving this string problem. im new to vc6 so hope you guys could help me. anyway here is my problem.
i had a string something like this
123456nn1n2nn4n5nnAnBnCnnDEFnnnn
n is null character
i want to split the string to an array but i dont know how. iv tried strtok method but i only get 123456. the rest is truncated.
i could do it in vb like this
dim i as integer
dim s() as string
s = split(thestring, vbnullchar)
for i = 0 to ubound(s)
debug.print s(i)
next
the output is
123456
12
45
ABC
DEF
that is the output i want.
hope you guys understand what i mean and could help me solve this problem.
thanks in advance :)
May 28, 2011 at 12:39pm UTC
iv tried strtok method but i only get 123456.
What did you set as the delimiting character?
A null-character denotes the end of a string. Although, I don't know if
strtok( ) considers the first null-character as the end of the string.
Also, it would be easier to help you if you posted the code.
Last edited on May 28, 2011 at 12:44pm UTC
May 28, 2011 at 12:59pm UTC
just read char by char, when you get to a null char start a new line, discard following null chars, repeat.
when you hit a null maybe go into a while loop,
1 2 3 4 5 6 7 8 9
//get character
if (char is null)
{
//start new line
while (ch == '\n' )
{
inf.get(ch);
}
}
that way the subsequent nulls are read in and discarded.
Last edited on May 28, 2011 at 1:00pm UTC
May 31, 2011 at 11:53am UTC
ok i finally solve my problem. thanks for the reply.
how did i solve it? well it was a unicode conversation problem. other than that was fine )