this library helps you for using Local File System
lfs_useful.h@9:9da7f151616a, 2015-04-20 (annotated)
- Committer:
- hirokimineshita
- Date:
- Mon Apr 20 08:14:05 2015 +0000
- Revision:
- 9:9da7f151616a
- Parent:
- 8:38e295ef7892
2015/04/20 PM 5 remake (int) read_some
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 | 9:9da7f151616a | 14 | double temp; |
hirokimineshita | 9:9da7f151616a | 15 | for(int i=0; i<num; i++){ |
hirokimineshita | 9:9da7f151616a | 16 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 9:9da7f151616a | 17 | fscanf(f,"%lf",&temp); |
hirokimineshita | 9:9da7f151616a | 18 | ar[i]=(int)temp; |
hirokimineshita | 9:9da7f151616a | 19 | } |
hirokimineshita | 8:38e295ef7892 | 20 | } |
hirokimineshita | 8:38e295ef7892 | 21 | |
hirokimineshita | 8:38e295ef7892 | 22 | /** (float)read_some function : |
hirokimineshita | 8:38e295ef7892 | 23 | * @bref read some member of csv format document in local file and write in arrangement |
hirokimineshita | 8:38e295ef7892 | 24 | * @param f write FILE *(name) 's name |
hirokimineshita | 8:38e295ef7892 | 25 | * @param ar arrangement which you want to get data |
hirokimineshita | 8:38e295ef7892 | 26 | * @param num the number of elements you want to get |
hirokimineshita | 8:38e295ef7892 | 27 | */ |
hirokimineshita | 8:38e295ef7892 | 28 | void read_some(FILE *f,float *ar,int num){ |
hirokimineshita | 8:38e295ef7892 | 29 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 8:38e295ef7892 | 30 | for(int i=0; i<num-1; i++)fscanf(f,"%f,",&ar[i]); |
hirokimineshita | 8:38e295ef7892 | 31 | fscanf(f,"%f",&ar[num-1]); |
hirokimineshita | 8:38e295ef7892 | 32 | } |
hirokimineshita | 8:38e295ef7892 | 33 | |
hirokimineshita | 8:38e295ef7892 | 34 | /** (double)read_some function : |
hirokimineshita | 5:6e1bb72b0905 | 35 | * @bref read some member of csv format document in local file and write in arrangement |
hirokimineshita | 5:6e1bb72b0905 | 36 | * @param f write FILE *(name) 's name |
hirokimineshita | 5:6e1bb72b0905 | 37 | * @param ar arrangement which you want to get data |
hirokimineshita | 5:6e1bb72b0905 | 38 | * @param num the number of elements you want to get |
hirokimineshita | 5:6e1bb72b0905 | 39 | */ |
hirokimineshita | 5:6e1bb72b0905 | 40 | void read_some(FILE *f,double *ar,int num){ |
hirokimineshita | 6:dbe54101d32f | 41 | if(fgetc(f)!=',')fseek(f,-1L,SEEK_SET); |
hirokimineshita | 6:dbe54101d32f | 42 | for(int i=0; i<num-1; i++)fscanf(f,"%lf,",&ar[i]); |
hirokimineshita | 6:dbe54101d32f | 43 | fscanf(f,"%lf",&ar[num-1]); |
hirokimineshita | 5:6e1bb72b0905 | 44 | } |
hirokimineshita | 0:48f30ad8e377 | 45 | |
hirokimineshita | 0:48f30ad8e377 | 46 | #endif |