SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void leggiMatrice(int M[MAXR][MAXR], int *nr, int *nc){
  2.    int i=0, j=0, rmax=0, cmax=0;
  3.    char s[MAXR+1], str[2]=" ", *token;
  4.    FILE *fp;
  5.    fp=fopen("mappa.txt", "r");
  6.    for(i=0; i<MAXR && (fgets(s, MAXR+1, fp))!=NULL; i++){
  7.        j=0;
  8.        token=strtok(s, str);
  9.        while( token != NULL){
  10.            M[i][j]=atoi(token);
  11.            j++;
  12.            if(j>cmax){
  13.                cmax=j;
  14.            }
  15.            token=strtok(NULL, str);
  16.        }
  17.        if(i>rmax){
  18.            rmax=i;
  19.        }
  20.    }
  21.    *nr=rmax;
  22.    *nc=cmax;
  23.    fclose(fp);
  24.  
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top