Re: [Vala] Is this a bug in VALA ?
- From: Arkadi Viner <arkashkin gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] Is this a bug in VALA ?
- Date: Sun, 6 Sep 2009 17:29:38 +0300
By the way I have found how to print on screen a gLong:
stdout.printf ("index - %ld ,Len() - %ld\n" ,index,line.len());
*so know I see:*
Line - happy doggy
<b>Process return 0 execution time: 0.007747 s</b>
index - 5 ,Len() - 11
Col1 - happy ,Col2 - s%
but why col2 not equals "doggy" ???
On Sun, Sep 6, 2009 at 5:12 PM, Arkadi Viner <arkashkin gmail com> wrote:
Hello.
I am trying to split a string into two strings.
The string should be split-ed by locating a first space character from the
left.
Please look at a simple code I made:
public class Main
{
public static int main (string[] args)
{
long index = 0;
string col1,col2;
string line = "happy doggy";
for(;index<=line.len();index++)
if(line[index] == ' ') break;
col1 = line.substring(0,index);
col2 = line.substring(index+1,line.len());
stdout.printf ("Line - %s\n", line);
stdout.printf ("index - %f ,Len() - f%\n" ,index,line.len());
stdout.printf ("Col1 - %s ,Col2 - s%\n" ,col1,col2);
return 0;
}
}
*When I compile this code I get:*
/home/arkadi/Bug/main.vala.c: In function ‘main_main’:
/home/arkadi/Bug/main.vala.c:113: warning: unknown conversion type
character 0xa in format
/home/arkadi/Bug/main.vala.c:114: warning: unknown conversion type
character 0xa in format
<b>Process return 0 execution time: 0.674968 s</b>
*When I run this code I get:*
Line - happy doggy
<b>Process return 0 execution time: 0.008026 s</b>
index - 5.000000 ,Len() - f%
** (process:7502): CRITICAL **: string_substring: assertion `(offset + len)
<= string_length' failed
Col1 - happy ,Col2 - s%
You can see that, It finds the place where to split the string very well
(5.000000) and col1="happy"
,but for the second part, line.Len() = f% and col2 = s%...
I have tried to change line.len() to numbers, but it's not the problem...
How to get col2="doggy" ???
Maybe some one know what is the problem with this code? or maybe it is
really a bug?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]