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