I am working on a code that reads a CSV file and sorts it into separate arrays.
I'm not sure what I'm doing wrong, but I'm getting "assignment makes integer from pointer without a cast" at each first line of the internal while loops (the ones that only have "{" in them). Anyone have a clue what I'm doing wrong?
Code:/*read file*/ char arra [2000] [100] ; char line [2000]; for( row = 0; row < 2000; row++ ) for( column = 0; column < 100; column++ ) arra [row] [column] = '\0' ; for (row = 0; row < 5; row++) line [row] = '\0' ; if ( fp != NULL) { while (fgets (line, sizeof line, fp ) != NULL) /*read a line*/ { strcpy (arra[row], line) ; /*printf ("array --> %s", &arra[row]) ;*/ row++; } /*split up rows into separate arrays*/ char codes [2000][4] ; char names [2000][15] ; char alts [2000][10]; char lats [2000][10] ; char longis [2000][10] ; char states [2000][2]; int character = 0 ; char temp ; char *check ; char *comma ; row = 1 ; check = arra[row,character] ; comma = ',' ; for ( row = 1; row <2000 ; row ++) while ( strcmp ( check, comma ) != 0 ) { temp = arra [row, character] ; codes [row, character ] = temp ; character++ ; check = arra[row,character] ; } while ( strcmp ( check, comma ) != 0 ) { temp = arra [row, character] ; names[row][character] = temp ; character++ ; check = arra[row,character] ; } while ( strcmp ( check, comma ) != 0 ) { temp = arra [row, character] ; states[row][character] = temp ; character++ ; check = arra[row,character] ; } while ( strcmp ( check, comma ) != 0 ) { temp = arra [row, character] ; lats[row][character] = temp ; character++ ; check = arra[row,character] ; } while ( strcmp ( check, comma ) != 0 ) { temp = arra [row, character] ; longis[row][character] = temp ; character++ ; check = arra[row,character] ; } while ( strcmp ( check, '\n' ) != 0 ) { temp = arra [row, character] ; alts[row][character] = temp ; character++ ; check = arra[row,character] ; } fclose(fp) ; } else { perror( filename) ; }



LinkBack URL
About LinkBacks


