#include <stdio.h>
#include <ncurses.h>
#include <fcntl.h>
#define BUFFSIZE 4096
#define LOGFILE "plik.txt"
main()
{
int file_fd;
int a;
char buff[BUFFSIZE];
file_fd = open(LOGFILE,O_RDONLY);
WINDOW *ok = initscr();
scrollok(ok,1);
while(1){
for ( a = 0; a < BUFFSIZE; a++ ) buff[a] = \ 0;
if((read(file_fd,buff,sizeof(buff))) < 0 ) {
endwin(); return 1;
}
refresh();
printw("[logfile] %s", buff);
}
endwin();
}
Jak zrobic zeby gdy odpalam program, to jak wyswietla mi zawartosc LOGFILE, i gdy ona dobiegnie konca, to wyswietla mi tylko non stop:
[ logfile ][ logfile ][ logfile ] itd, bez konca, jak to poprawic, zeby to sie nie dzialo ? :)
thx