41 lines
905 B
Vala
41 lines
905 B
Vala
class Foo {
|
|
public unowned string s = "";
|
|
}
|
|
|
|
public int main () {
|
|
var s = "Hello, world!";
|
|
|
|
var foo = new Foo ();
|
|
|
|
foo.s = s;
|
|
|
|
//string tmps = s[0:5];
|
|
unowned string tmps = (string)((char*)s + 3);
|
|
|
|
((char *)s)[3] = 'A';
|
|
|
|
stdout.printf ("%s\n", s);
|
|
stdout.printf ("%s\n", foo.s);
|
|
|
|
stdout.printf ("%s\n", tmps);
|
|
|
|
stdout.printf ("%s\n", tmps[0:1]);
|
|
stdout.printf ("%s\n", tmps.ndup (1));
|
|
stdout.printf ("%s\n", tmps.substring (2, 3));
|
|
stdout.printf ("%s\n", tmps[2:3]);
|
|
stdout.printf ("%s\n", tmps.chr (100, 'o'));
|
|
//stdout.printf ("%s\n", Posix.strchr (tmps, 'o'));
|
|
|
|
print ("----\n");
|
|
stdout.printf ("%s\n", tmps);
|
|
stdout.printf ("%s\n", tmps.offset (3)[0:-1]);
|
|
|
|
for (var i = 0, max_i = tmps.length; i < max_i; ++i)
|
|
stdout.printf ("%c", tmps[i]);
|
|
stdout.printf ("\n");
|
|
|
|
stdout.printf ("%p = '%s'[%u]\n", tmps.offset (100), tmps.offset (100), tmps.offset (100).length);
|
|
|
|
return 0;
|
|
}
|