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);
- //bool isborder(Map *map, int r, int c, int border);
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // MAIN //
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- typedef struct{
- int rows;
- int cols;
- unsigned char *cells;
- } Map;
- int main(int argc, char *argv[]){
- Map mapa;
- mapa.rows = atoi(argv[2]);
- mapa.cols = atoi(argv[3]);
- if (argc > 5)
- fprintf(stderr,"Invalid number of arguments.\n");
- /* 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 rightHand;
- break;
- default;
- }*/
- FILE *fp = fopen("bludiste.txt", "r");
- mapa.cells=malloc(sizeof(unsigned char)*mapa.rows*mapa.cols);
- for(int i = 0; i < mapa.rows*mapa.cols; i++){
- char c=fgetc(fp);
- if(c!=' ' && c!= '\n'){
- mapa.cells[i]=c;
- }
- else{
- i--;
- }
- printf("nacitanie do %d\n", i);
- // fscanf(fp, "%s", &mapa.cells[i]);
- }
- printf("medzi for \n");
- //for(int i = 0; i < mapa.rows*mapa.cols-1; i++){
- printf("%s \n", mapa.cells);
- //printf("vypisanie do %d\n", i);
- //}
- printf("fin\n");
- 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]);
- }
- }
- }
- */
- /*bool isborder(Map *map, int r, int c, int border){
- switch (border) {
- case 1:
- if (map.cells[map.cols*(r-1)+c] == (1 || 3 || 5 || 7)) {
- return true;
- }else{
- return false;}
- break;
- case 2:
- if (map.cells[map.cols*(r-1)+c] == (2 || 3 || 6 || 7)) {
- return true;
- }else{
- return false;}
- break;
- case 3:
- if (map.cells[map.cols*(r-1)+c] == (4 || 5 || 7 || 6)) {
- return true;
- }
- else{
- return false;}
- break;
- default:
- break;
- }
- }*/
- //void leftHand()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement