-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_data.c
More file actions
37 lines (33 loc) · 756 Bytes
/
Copy pathimport_data.c
File metadata and controls
37 lines (33 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
// Import numeric txt file data into C using fscanf
// See data/ for examples
#define MAX_LINE_LENGTH 80
static int sum(int val){
static int value;
value += val;
return value;
}
int main(){
printf("Started\n\r");
int num;
int a;
int line[MAX_LINE_LENGTH]={0};
FILE *fptr;
fptr = fopen("data/LeftLegAngleData.txt","r");
if(fptr == NULL)
{
printf("Error This file does not exist\n\r");
exit(1);
}
fscanf(fptr,"%d", &num);
printf("The first value is = %d\n\r",num);
while(!feof(fptr)){
fscanf(fptr,"%d", &num);//imported
//a = sum(num);
//printf("The next value is = %d\n\r",num);
}
printf("done import");
fclose(fptr);
return 0;
}