Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shelby!csli!gandalf From: gandalf@csli.STANFORD.EDU (Juergen Wagner) Newsgroups: comp.lang.c Subject: Re: Where oh where is my directory Message-ID: <8279@csli.STANFORD.EDU> Date: 25 Mar 89 04:00:30 GMT References: <7712@pyr.gatech.EDU> Sender: gandalf@csli.Stanford.EDU (Juergen Wagner) Reply-To: gandalf@csli.stanford.edu (Juergen Wagner) Organization: Center for the Study of Language and Information, Stanford U. Lines: 42 In article <7712@pyr.gatech.EDU> perrone@loligo.UUCP (Perrone Ford) writes: >What I am trying to accompish is to read the directory >entries into a buffer and then print the buffer out in the >middle of a graphics routine Basically, there are two ways: call a program like "ls" (UNIX), or do it yourself. I reckon your problem is not an ANSI/non-ANSI problem, it's more an operating system problem. >#include >#include /* Maybe curses */ >main () >{ >char *listing; >listing = system("dir"); >initgraph = DETECT; >initgraph(&graphdriver, &graphmode); >outtext(listing); >} Sure your screen gets trashed. The problem is that your call to "dir" doesn't return a list of file names neatly packed into a string, it returns an integer (probably :-). I have no idea what exactly is possible on your system but try to look for one of the following: (a) Something like opendir(), readdir(), closedir() to access directory entries, and collect them into a string. Even better, print them as you read them. (b) Something forking a subprocess which allows you to collect the output of the subprocess in some way (popen would be nice). (c) In the worst case, call a program doing what you want, have the program write its output to a file, and read that file. I can promise you that it'll be sloooow but it will work. Good luck, -- Juergen Wagner gandalf@csli.stanford.edu wagner@arisia.xerox.com