source: CIVL/examples/io/fscanf.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: 621 bytes
RevLine 
[ed451d9]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 */
[9803bc1]8#include<civlc.cvh>
[3ec9585]9#include<stdio.h>
[6f8bc6ea]10#include<civl-stdio.cvh>
11
[abd3108]12int fooLength = $text_file_length("foo");
[3ec9585]13
[3ff27cf]14$assume(fooLength == 5);
[3ec9585]15
16void 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 }
[f3282f0]28 $free(file);
[3ec9585]29}
Note: See TracBrowser for help on using the repository browser.