C: Reading a file into an array -
I have a text file and I have to read it line by line and put the rows in an array.
Returns the snippet error behind compiling:
file * f; Four line [LINE_SIZE]; Four * line; Int num_righe; F = fopen ("spese.dat", "r"); If (f == tap) {f = fopen ("spese.dat", "w"); } While (fgets (line, LINE_SIZE, f)} {num_righe ++; Lines = reall (lines, (size) (* LINE_SIZE) * num_righe); Strcpy (line [num_righe-1], line); } Fclose (f); Error:
spese.c: 29: Warning: Assignment creates an integer without a pointer spaces.c: 30: Warning: Incompatible underlying function 'strcpy' the underlying declaration spese.c: 30: WARNING: Argument of 'strcpy' creates an index without integer without an artist Any help? Thanks
Try:
FILE * f; Four line [LINE_SIZE]; Four ** line = zero; Int num_righe = 0; F = fopen ("spese.dat", "r"); If (f == tap) {f = fopen ("spese.dat", "w"); } While (fgets (line, LINE_SIZE, f)} {num_righe ++; Lines = (four **) reioco (lines, shapes (four *) * digits_ifery); Line [num_righe-1] = stdup (line); } Fclose (f);
Comments
Post a Comment