Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // proj3.c
- // IZP
- // Created by Patrik Smola on 06/12/2019.
- // xsmola08
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // FUNCTIONS PROTOTYPES //
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //void getMatrix(int rows, int cols, FILE *fp);
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // MAIN //
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- typedef struct{
- int rows;
- int cols;
- unsigned char *cells[];
- } Map;
- int main(int argc, char *argv[]){
- Map mapa;
- if ((argc != 2) || (argc != 3) || (argc != 5))
- fprintf(stderr,"Invalid number of arguments.");
- return 1;
- /* a = getopt_long(argc, argv, "help:test:lhand:rhand");
- if (a == -1)
- break;
- switch(a){
- case 'help'
- fprintf(stdout,"Napoveda");
- break;
- case 'test'
- testMap;
- break;
- case 'lhand'
- int leftHand;
- break;
- case 'rhand'
- int righHand;
- break;
- default;
- }*/
- FILE *fp = fopen(argv[4], "r");
- mapa.rows = (int)argv[2];
- mapa.cols = (int)argv[3];
- //mapa.cells[mapa.rows*mapa.cols];
- for(int i = 0; i < mapa.rows*mapa.cols; i++){
- fscanf(fp, "%u ", (unsigned int)mapa.cells[i]);
- }
- for(int i = 0; i < mapa.rows*mapa.cols; i++){
- printf("%u ", (unsigned int)mapa.cells[i]);
- }
- fclose(fp);
- return 0;
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // FUNCTION DEFINITIONS //
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /*void getMatrix(int rows, int cols, FILE *fp){
- for(int i = 0; i < rows; i++){
- for(int j = 0; j < cols; j++){
- cells[i][j] = fscanf(fp);
- }
- }
- for(int i = 0; i < rows; i++){
- for(int j = 0; j < cols; j++){
- printf("%u ", cells[i][j]);
- }
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement