Why does my buff [0] print the last line of the file, and how can I make all the elements of the array available outside the loop?
FILE *fp; fp = fopen("test.db", "rb"); int i = 0; char str[126]; char *buff[126]; while (!feof(fp)) { if (fgets(str, 126, fp)) { buff[i] = str; } i++; } printf("%sn", buff[0]);