Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <assert.h>
  4. #include <math.h>
  5. #include <limits.h>
  6. #include <unistd.h>
  7.  
  8. int k;
  9. char* filename;
  10.  
  11. typedef struct{
  12. int x;
  13. int y;
  14. }point;
  15.  
  16. int main(int argc, char* argv[])
  17. {
  18. char c;
  19. while((c = getopt(argc, argv, "f:k:"))!= -1 )
  20. {
  21. switch(c)
  22. {
  23. case 'f':
  24. filename = optarg;
  25. break;
  26. case 'k':
  27. k = atoi(optarg);
  28. break;
  29. exit(1);
  30. default:
  31. printf("arguments not added in correctly");
  32. exit(1);
  33. }
  34. }
  35. printf("file name is %s \n", filename);
  36. printf("k is %d \n", k);
  37.  
  38.  
  39. //save the data from the text file that you are getting
  40. point dataBank[k];
  41.  
  42. FILE* infile;
  43. // printf("it comes here") ;
  44. float* xPoint = malloc(sizeof(float));
  45. float* yPoint = malloc(sizeof(float));
  46.  
  47. infile = fopen(filename, "r");
  48. while(fscanf(infile, "%f, %f", xPoint, yPoint) != EOF)
  49. {
  50. printf(" x is %f and y is %f \n", *xPoint, *yPoint);
  51. }
  52.  
  53.  
  54. }
Add Comment
Please, Sign In to add comment