Cheat-sheet for strings
This commit is contained in:
parent
c7d99743bd
commit
af175ddda1
|
@ -100,6 +100,29 @@ let z = 2
|
|||
<tr>
|
||||
<td>
|
||||
```C
|
||||
char* s = "Hello World.";
|
||||
char s0 = s[0]; // 'H'
|
||||
char *t = s; // Pointer to s
|
||||
s[11] = '!';
|
||||
// s and t are both "Hello World."
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```Nimrod
|
||||
var s: string = "Hello World."
|
||||
var s0: char = s[0] # 'H'
|
||||
var t = s # Copy of s
|
||||
s[11] = '!'
|
||||
# s is "Hello World!", t is "Hello World."
|
||||
```
|
||||
</td>
|
||||
<td><b>Strings and char</b>. Strings are pass-by-value (copied on assignment) and strictly bounds-checked on access.</i>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
```C
|
||||
9 % 8 // 1
|
||||
-9 % 8 // -1
|
||||
(unsigned)(-9) % (unsigned)(8) // 7
|
||||
|
|
Loading…
Reference in New Issue