Last change
on this file since 1 was
1,
checked in by lnalod, 15 years ago
|
Initial import of YAO sources
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | |
---|
5 | #define BUFSIZE 80 |
---|
6 | |
---|
7 | int main (int argc, char *argv[]) |
---|
8 | { /* . Syntaxe : yf2m f1 mf ncol |
---|
9 | . Purpose : file (f1) to matlab matrice file (mf) ; |
---|
10 | ncol is the number of column of the matrice. |
---|
11 | . Compilation : cc -Wall -o yf2m yf2m.c */ |
---|
12 | |
---|
13 | FILE *f1, *mf; |
---|
14 | char buf[BUFSIZE+1]; |
---|
15 | int ncol; |
---|
16 | int icol, nblig; |
---|
17 | |
---|
18 | if ((f1 = fopen(argv[1], "r")) <= 0) |
---|
19 | { printf ("yao file %s not found !!!\n", argv[1]); |
---|
20 | exit(0); |
---|
21 | } |
---|
22 | if ((mf = fopen(argv[2], "w")) <= 0) |
---|
23 | { printf ("failed while opening matlab file %s !!!\n", argv[2]); |
---|
24 | exit(0); |
---|
25 | } |
---|
26 | |
---|
27 | ncol = atoi(argv[3]); |
---|
28 | if (ncol<=0) |
---|
29 | { printf ("bad value for ncol \n"); |
---|
30 | exit(0); |
---|
31 | } |
---|
32 | |
---|
33 | icol=0; nblig=0; |
---|
34 | //while (fgets (buf, BUFSIZE, f1) != NULL) |
---|
35 | while (fscanf(f1, "%s", buf) > 0) |
---|
36 | { |
---|
37 | fprintf(mf, "%s", buf); //printf("%s", buf); |
---|
38 | icol = (icol+1)%ncol; |
---|
39 | if (icol) fprintf(mf, "\t"); //printf("\t"); |
---|
40 | else |
---|
41 | { fprintf(mf, "\n"); //printf("\n"); |
---|
42 | ++nblig; |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | if (icol != 0) |
---|
47 | printf("\nyf2m: Warning : last line not complete : only %i elt instead of %i \n", icol, ncol); |
---|
48 | |
---|
49 | printf ("yf2m: %i line resumed\n", nblig); |
---|
50 | return(0); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
Note: See
TracBrowser
for help on using the repository browser.