source: CIVL/examples/languageFeatures/stringTest.cvl

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
RevLine 
[c6291e9]1#include <string.h>
2#include <stdlib.h>
3#include <civlc.cvh>
[d66b03b]4$scope root = $here;
[c6291e9]5int main(){
6
[d66b03b]7 char * strin = (char*)$malloc(root, sizeof(char) * 4);
[c6291e9]8 //copy by strcpy()
[d66b03b]9 char * cpystr = (char*)$malloc(root, sizeof(char) * 4);
[c6291e9]10 //copy by memcpy()
[d66b03b]11 char * memstr = (char*)$malloc(root, sizeof(char) * 4);
[c6291e9]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);
[d980649]23 $assert(ret == 0);
[c6291e9]24 ret = strcmp(memstr, strin);
[d980649]25 $assert(ret == 0);
[c6291e9]26 // Following statements are waiting for int2char bug fixing
27 // ret = strcmp("add", strin);
[3ff27cf]28 // $assert((ret == 0));
[c6291e9]29 $free(strin);
30 $free(cpystr);
31 $free(memstr);
32 return 0;
33}
Note: See TracBrowser for help on using the repository browser.