Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. // proj3.c
  2. // IZP
  3. // Created by Patrik Smola on 06/12/2019.
  4. // xsmola08
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include <unistd.h>
  10.  
  11. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  12. // FUNCTIONS PROTOTYPES //
  13. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  14.  
  15. //void getMatrix(int rows, int cols, FILE *fp);
  16.  
  17. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. // MAIN //
  19. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  20.  
  21. typedef struct{
  22. int rows;
  23. int cols;
  24. unsigned char *cells[];
  25. } Map;
  26.  
  27. int main(int argc, char *argv[]){
  28. Map mapa;
  29. if ((argc != 2) || (argc != 3) || (argc != 5))
  30. fprintf(stderr,"Invalid number of arguments.");
  31. return 1;
  32.  
  33. /* a = getopt_long(argc, argv, "help:test:lhand:rhand");
  34. if (a == -1)
  35. break;
  36. switch(a){
  37. case 'help'
  38. fprintf(stdout,"Napoveda");
  39. break;
  40.  
  41. case 'test'
  42. testMap;
  43. break;
  44.  
  45. case 'lhand'
  46. int leftHand;
  47. break;
  48.  
  49. case 'rhand'
  50. int righHand;
  51. break;
  52. default;
  53. }*/
  54.  
  55. FILE *fp = fopen(argv[4], "r");
  56.  
  57.  
  58. mapa.rows = (int)argv[2];
  59. mapa.cols = (int)argv[3];
  60. //mapa.cells[mapa.rows*mapa.cols];
  61. for(int i = 0; i < mapa.rows*mapa.cols; i++){
  62.  
  63. fscanf(fp, "%u ", (unsigned int)mapa.cells[i]);
  64.  
  65. }
  66. for(int i = 0; i < mapa.rows*mapa.cols; i++){
  67.  
  68. printf("%u ", (unsigned int)mapa.cells[i]);
  69.  
  70. }
  71.  
  72. fclose(fp);
  73. return 0;
  74. }
  75.  
  76.  
  77. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78. // FUNCTION DEFINITIONS //
  79. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81.  
  82. /*void getMatrix(int rows, int cols, FILE *fp){
  83. for(int i = 0; i < rows; i++){
  84. for(int j = 0; j < cols; j++){
  85. cells[i][j] = fscanf(fp);
  86. }
  87. }
  88. for(int i = 0; i < rows; i++){
  89. for(int j = 0; j < cols; j++){
  90. printf("%u ", cells[i][j]);
  91. }
  92. }
  93. }
  94. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement