Standard Library file io under windows

This is a discussion on Standard Library file io under windows within the Windows Programming forums, part of the Platform Specific Boards category; How does the C runtime library do file i/o in a windows app? The WinAPI has only the CreateFile and ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    70

    Standard Library file io under windows

    How does the C runtime library do file i/o in a windows app? The WinAPI has only the CreateFile and ReadFile as far as I can see where ReadFile reads a specified number of bytes rather than until lineend. So if one uses fgets to get a line at the time, does it use a 1-sized buffer until newline is detected? Does it use DOS routines? I'd like to use those funcs as described directly myself unless that's a terribly inefficient way to do it.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    It probably uses ReadFile to read a whole buffer full of bytes, then copies up to the first newline into the buffer you supply to gets
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21