source: CIVL/examples/languageFeatures/linkedListMinimal.cvl@ 90dd7d7

1.23 2.0 main test-branch
Last change on this file since 90dd7d7 was 8fa5a7b, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

moved untested/unused examples to experimental folder

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

  • Property mode set to 100644
File size: 607 bytes
Line 
1#include<civlc.h>
2
3$input int N;
4$assume N > 0 && N <= 2;
5
6typedef struct Node {
7 double value;
8 struct Node* next;
9} Node;
10
11void main() {
12 $heap h;
13 Node* head;
14 Node* current = (Node *) $malloc(&h, sizeof(Node));
15 Node final;
16
17 head = current;
18 head->value = 0.0;
19 {
20 Node* newNode = (Node *) $malloc(&h, sizeof(Node));
21
22 newNode->value = 2.71828;
23 current->next = newNode;
24 current = newNode;
25 }
26 current->next = NULL;
27 final = *head;
28 while (final.next != NULL) {
29 final = *(final.next);
30 }
31 $assert final.value == 2.71828;
32 $assert final.value == current->value;
33}
Note: See TracBrowser for help on using the repository browser.