source:
CIVL/mods/dev.civl.com/examples/library/string/string_test.cvl@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 336 bytes | |
| Line | |
|---|---|
| 1 | #include <civlc.cvh> |
| 2 | #include<stdlib.h> |
| 3 | #include<string.h> |
| 4 | |
| 5 | void main(){ |
| 6 | char* s; |
| 7 | int len; |
| 8 | |
| 9 | s = (char*)malloc(sizeof(char) * 5); |
| 10 | |
| 11 | //s[0] = 'a'; |
| 12 | //s[1] = 'b'; |
| 13 | strcpy(s, "abcd"); |
| 14 | int x = strcmp(s, "abcd"); |
| 15 | $assert(x==0); |
| 16 | len = strlen(s); |
| 17 | $assert(len == 4); |
| 18 | len = strlen(s + 1); |
| 19 | $assert(len == 3); |
| 20 | free(s); |
| 21 | } |
Note:
See TracBrowser
for help on using the repository browser.
