You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn to_upper(s string) -> string {
unsafe {
mut b := mem.alloc(s.len + 1)
for i in 0 .. s.len {
if s.str[i] >= `a` && s.str[i] <= `z` {
b[i] = s.str[i] - 32
} else {
b[i] = s.str[i]
}
}
b[s.len] = 0
return tos(b)
}
}
C compiler output:
/home/yuart/Projects/spawn/out.c: In function ‘main___to_upper’:
/home/yuart/Projects/spawn/out.c:1349:43: error: subscripted value is neither array nor pointer nor vector
1349 | if (!((string__str[i] < 'a')) && (string__str[i] < 'z' || string__str[i] == 'z')) {
| ^
/home/yuart/Projects/spawn/out.c:1349:70: error: subscripted value is neither array nor pointer nor vector
1349 | if (!((string__str[i] < 'a')) && (string__str[i] < 'z' || string__str[i] == 'z')) {
| ^
/home/yuart/Projects/spawn/out.c:1349:94: error: subscripted value is neither array nor pointer nor vector
1349 | if (!((string__str[i] < 'a')) && (string__str[i] < 'z' || string__str[i] == 'z')) {
| ^
/home/yuart/Projects/spawn/out.c:1350:51: error: subscripted value is neither array nor pointer nor vector
1350 | b[i] = string__str[i] - 32;
| ^
/home/yuart/Projects/spawn/out.c:1352:51: error: subscripted value is neither array nor pointer nor vector
1352 | b[i] = string__str[i];
| ^
error: C compiler failed
Activity