Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!uc!uh!glex From: glex@uh.msc.umn.edu (Jeffrey Gleixner) Newsgroups: comp.lang.c Subject: fflush & curses Summary: output to window isn't correct Message-ID: <1061@uc.msc.umn.edu> Date: 9 Jan 90 04:53:05 GMT Sender: news@uc.msc.umn.edu Reply-To: glex@uh.UUCP (Jeffrey Gleixner) Organization: Minnesota Supercomputer Center, Minneapolis, MN Lines: 43 I wrote a C program using Curses that calls the following **str is "grep -l a_string `find Some_home_dir -type f -print`" ** void init_find_win(str) char *str; /* * makes a window showing the files that are found */ { FILE *pipe; char buf[BUFSIZ]; int i=0,j; buf[0]=NULL; if((pipe = popen(str, "r")) == NULL) { perror("init_find_win: popen"); exit(0); } while ((fgets(buf, 40, pipe) != NULL) && i<19) { mvwprintw(f_win, ++i, 0, "* %-45s", buf); mvwprintw(f_win, i, 44, "*"); } mvwprintw(f_win, i++,0, ">> Control-w - pulls up this window. <<"); ... the rest deleted.... } This works fine except it seems to "miss" a few files. i.e. if I execute the same grep... command in the correct directory it finds more files with the string. I thought that the output from the pipe wasn't being flushed to the window, so I tried fflush (stdout) , fflush (f_win), fflush (pipe) but nothing seems to print all of the files to the window. It does search through all of the files ( if I look for an 'e' it prints out a 19 files). This is really strange. %-( thanks in advance. Please try E-mail first glex@msc.umn.edu