From: an118 AT chebucto DOT ns DOT ca (Graham Howard Wile) Newsgroups: comp.os.msdos.djgpp Subject: NEED HELP with "_read()" Date: 7 Dec 1996 22:20:31 GMT Organization: Chebucto Community Net Lines: 59 Message-ID: <58cqjf$6ie@News.Dal.Ca> NNTP-Posting-Host: chebucto.ns.ca To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In the "libc" documentation file, it tells how to use "_read()" by showing that you need to feed it these parameters: ssize_t _read(int fildes, void *buf, size_t nbyte); The parameter I am having trouble with is the "int fildes". In the example in the file "libc" they write: int r = read(0, buf, 10); I notice they use a "0" for the file description number. Are you always suppossed to use 0? If not, how do you know what number represents the file you just opened with "fopen"? Below is some code I work which compiles great, but locks up on the line: bytes_read = _read(0, read_into_buffer, 10); Here is my code: #include #include #include void main() { char read_into_buffer[60]; int bytes_read, file_number; FILE *f = fopen("testing.txt", "rt"); cout << "Pointer: " << f << endl; bytes_read = _read(0, read_into_buffer, 10); fclose(f); } The file opens well, and the "cout << "Pointer: " << f << endl;" even returns a valid non-zero address to my file object. But it hangs and doesn't return a value for the number of bytes read at the line: bytes_read = _read(0, read_into_buffer, 10); I'm assuming the parameter 0 isn't the right one for the opened file "testing.txt", as since I am in windows, a lot of other files are open at this time as well. If I am right, how does one determine the correct number to enter for this parameter ? Thank-you Graham H. W.