source: CIVL/examples/languageFeatures/stringTest.cvl@ a6d2043

1.23 2.0 main test-branch
Last change on this file since a6d2043 was d980649, checked in by Manchun Zheng <zmanchun@…>, 10 years ago

fixed extra parenthesis.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2922 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 732 bytes
RevLine 
[c6291e9]1#include <string.h>
2#include <stdlib.h>
3#include <civlc.cvh>
4
5int 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);
[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.