main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
749 bytes
|
| Line | |
|---|
| 1 | #include <string.h>
|
|---|
| 2 | #include <stdlib.h>
|
|---|
| 3 | #include <civlc.cvh>
|
|---|
| 4 | $scope root = $here;
|
|---|
| 5 | int main(){
|
|---|
| 6 |
|
|---|
| 7 | char * strin = (char*)$malloc(root, sizeof(char) * 4);
|
|---|
| 8 | //copy by strcpy()
|
|---|
| 9 | char * cpystr = (char*)$malloc(root, sizeof(char) * 4);
|
|---|
| 10 | //copy by memcpy()
|
|---|
| 11 | char * memstr = (char*)$malloc(root, sizeof(char) * 4);
|
|---|
| 12 | int ret;
|
|---|
| 13 |
|
|---|
| 14 | strin[0]='a';
|
|---|
| 15 | strin[1]='d';
|
|---|
| 16 | strin[2]='d';
|
|---|
| 17 | strin[3] = 0;
|
|---|
| 18 |
|
|---|
| 19 | strcpy(cpystr, strin);
|
|---|
| 20 | memcpy(memstr, strin, (sizeof(char) * 4));
|
|---|
| 21 |
|
|---|
| 22 | ret = strcmp(cpystr, strin);
|
|---|
| 23 | $assert(ret == 0);
|
|---|
| 24 | ret = strcmp(memstr, strin);
|
|---|
| 25 | $assert(ret == 0);
|
|---|
| 26 | // Following statements are waiting for int2char bug fixing
|
|---|
| 27 | // ret = strcmp("add", strin);
|
|---|
| 28 | // $assert((ret == 0));
|
|---|
| 29 | $free(strin);
|
|---|
| 30 | $free(cpystr);
|
|---|
| 31 | $free(memstr);
|
|---|
| 32 | return 0;
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.