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:
621 bytes
|
| Line | |
|---|
| 1 | /* This file is to demonstrate the file I/O function fscanf.
|
|---|
| 2 | * A file has unconstrained length by default. If you want to
|
|---|
| 3 | * specify the length of a file, you need to use the system
|
|---|
| 4 | * function $textFileLength() provided by civl-stdio.cvh.
|
|---|
| 5 | *
|
|---|
| 6 | * This program has no violation.
|
|---|
| 7 | */
|
|---|
| 8 | #include<civlc.cvh>
|
|---|
| 9 | #include<stdio.h>
|
|---|
| 10 | #include<civl-stdio.cvh>
|
|---|
| 11 |
|
|---|
| 12 | int fooLength = $text_file_length("foo");
|
|---|
| 13 |
|
|---|
| 14 | $assume(fooLength == 5);
|
|---|
| 15 |
|
|---|
| 16 | void main(){
|
|---|
| 17 | FILE *file = fopen("foo", "r");
|
|---|
| 18 | int a[5];
|
|---|
| 19 | int i = 0;
|
|---|
| 20 |
|
|---|
| 21 | while($true){
|
|---|
| 22 | int count = fscanf(file, "%d", &a[i]);
|
|---|
| 23 |
|
|---|
| 24 | if(count == EOF)
|
|---|
| 25 | break;
|
|---|
| 26 | i++;
|
|---|
| 27 | }
|
|---|
| 28 | $free(file);
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.