I want to write a program in C which just reads a file, stores it into an array and then prints the array. Everything works fine but when the text file has more than one line, I always just get the last line printed out.
This is my Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
   FILE * stream;
   char dateiname[255];
   stream = fopen("heute.txt", "r");
   if(stream == NULL){
      printf("Error");
      }else {
          while(!feof(stream)){
             fgets(dateiname, 255, stream);
      }
    fclose(stream);
    }
printf("%s\n", dateiname);
}
Thanks for help!
 
     
    