this library helps you for using Local File System
lfs_useful.h@8:38e295ef7892, 2015-04-18 (annotated)
- Committer:
- hirokimineshita
- Date:
- Sat Apr 18 11:43:02 2015 +0000
- Revision:
- 8:38e295ef7892
- Parent:
- 7:e62c07f356a0
- Child:
- 9:9da7f151616a
2015/04/18 PM 8 be able to use int,float
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hirokimineshita | 0:48f30ad8e377 | 1 | #ifndef _LFS_USEFUR_H_20150417_1537_ |
hirokimineshita | 0:48f30ad8e377 | 2 | #define _LFS_USEFUR_H_20150417_1537_ |
hirokimineshita | 0:48f30ad8e377 | 3 | |
hirokimineshita | 7:e62c07f356a0 | 4 | /** @file |
hirokimineshita | 7:e62c07f356a0 | 5 | */ |
hirokimineshita | 7:e62c07f356a0 | 6 | |
hirokimineshita | 8:38e295ef7892 | 7 | /** (int)read_some function : |
hirokimineshita | 8:38e295ef7892 | 8 | * @bref read some member of csv format document in local file and write in arrangement |
hirokimineshita | 8:38e295ef7892 | 9 | * @param f write FILE *(name) 's name |
hirokimineshita | 8:38e295ef7892 | 10 | * @param ar arrangement which you want to get data |
hirokimineshita | 8:38e295ef7892 | 11 | * @param num the number of elements you want to get |
hirokimineshita | 8:38e295ef7892 | 12 | */ |
hirokimineshita | 8:38e295ef7892 | 13 | void read_some(FILE *f,int *ar,int num){ |
hirokimineshita | 8:38e295ef7892 | 14 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 8:38e295ef7892 | 15 | for(int i=0; i<num-1; i++)fscanf(f,"%d,",&ar[i]); |
hirokimineshita | 8:38e295ef7892 | 16 | fscanf(f,"%d",&ar[num-1]); |
hirokimineshita | 8:38e295ef7892 | 17 | } |
hirokimineshita | 8:38e295ef7892 | 18 | |
hirokimineshita | 8:38e295ef7892 | 19 | /** (float)read_some function : |
hirokimineshita | 8:38e295ef7892 | 20 | * @bref read some member of csv format document in local file and write in arrangement |
hirokimineshita | 8:38e295ef7892 | 21 | * @param f write FILE *(name) 's name |
hirokimineshita | 8:38e295ef7892 | 22 | * @param ar arrangement which you want to get data |
hirokimineshita | 8:38e295ef7892 | 23 | * @param num the number of elements you want to get |
hirokimineshita | 8:38e295ef7892 | 24 | */ |
hirokimineshita | 8:38e295ef7892 | 25 | void read_some(FILE *f,float *ar,int num){ |
hirokimineshita | 8:38e295ef7892 | 26 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 8:38e295ef7892 | 27 | for(int i=0; i<num-1; i++)fscanf(f,"%f,",&ar[i]); |
hirokimineshita | 8:38e295ef7892 | 28 | fscanf(f,"%f",&ar[num-1]); |
hirokimineshita | 8:38e295ef7892 | 29 | } |
hirokimineshita | 8:38e295ef7892 | 30 | |
hirokimineshita | 8:38e295ef7892 | 31 | /** (double)read_some function : |
hirokimineshita | 5:6e1bb72b0905 | 32 | * @bref read some member of csv format document in local file and write in arrangement |
hirokimineshita | 5:6e1bb72b0905 | 33 | * @param f write FILE *(name) 's name |
hirokimineshita | 5:6e1bb72b0905 | 34 | * @param ar arrangement which you want to get data |
hirokimineshita | 5:6e1bb72b0905 | 35 | * @param num the number of elements you want to get |
hirokimineshita | 5:6e1bb72b0905 | 36 | */ |
hirokimineshita | 5:6e1bb72b0905 | 37 | void read_some(FILE *f,double *ar,int num){ |
hirokimineshita | 6:dbe54101d32f | 38 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 6:dbe54101d32f | 39 | for(int i=0; i<num-1; i++)fscanf(f,"%lf,",&ar[i]); |
hirokimineshita | 6:dbe54101d32f | 40 | fscanf(f,"%lf",&ar[num-1]); |
hirokimineshita | 5:6e1bb72b0905 | 41 | } |
hirokimineshita | 0:48f30ad8e377 | 42 | |
hirokimineshita | 0:48f30ad8e377 | 43 | #endif |