Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <assert.h>
- #include <math.h>
- #include <limits.h>
- #include <unistd.h>
- int k;
- char* filename;
- typedef struct{
- int x;
- int y;
- }point;
- int main(int argc, char* argv[])
- {
- char c;
- while((c = getopt(argc, argv, "f:k:"))!= -1 )
- {
- switch(c)
- {
- case 'f':
- filename = optarg;
- break;
- case 'k':
- k = atoi(optarg);
- break;
- exit(1);
- default:
- printf("arguments not added in correctly");
- exit(1);
- }
- }
- printf("file name is %s \n", filename);
- printf("k is %d \n", k);
- //save the data from the text file that you are getting
- point dataBank[k];
- FILE* infile;
- // printf("it comes here") ;
- float* xPoint = malloc(sizeof(float));
- float* yPoint = malloc(sizeof(float));
- infile = fopen(filename, "r");
- while(fscanf(infile, "%f, %f", xPoint, yPoint) != EOF)
- {
- printf(" x is %f and y is %f \n", *xPoint, *yPoint);
- }
- }
Add Comment
Please, Sign In to add comment