source: CIVL/examples/languageFeatures/int2char.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: 504 bytes
RevLine 
[9803bc1]1#include <civlc.cvh>
[c6291e9]2#include <stdio.h>
3
4$input int num;
[3ff27cf]5$assume(num > 0 && num < 255);
[d66b03b]6
7$scope root = $here;
8
[c6291e9]9void main(){
10 char c[3];
11 char * pc;
12 int b = 98; // 'b'
13
[d66b03b]14 pc = (char*)$malloc(root, sizeof(char) * 3);
[c6291e9]15 c[0] = num;
16 c[1] = 'a';
17 c[2] = b - 1;
18
19 pc[0] = num;
20 pc[1] = b - 1;
21 pc[2] = 97;
22 //test symbolic int to char
[d980649]23 $assert(c[0] == pc[0]);
[c6291e9]24 //test if (char)(b-1) == 'a'
[d980649]25 $assert(c[1] == pc[1]);
[c6291e9]26 //test if (char)(98 - 1) == (char)97
[d980649]27 $assert(c[2] == pc[2]);
[c6291e9]28 $free(pc);
29}
Note: See TracBrowser for help on using the repository browser.