Thread: file i/o

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    9

    file i/o

    hello good people

    can someone plz give an example (if poss wit a brief explanation)
    on how to work with the funtions CreateFile, WriteFile, ReadFile.
    i'm a bit mixed up with the arguments.
    thanks in advance for your kind time

    1976

    "The truth is an amusing concept"

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    22
    Here's what I got for CreateFile and ReadFile

    Unsigned Char Buffer[50]={0};
    HANDLE hFile;
    DWORD ReadBytes = 16;
    DWORD dwRead;


    hFile= CreateFile("C:\\Temp\\Temp.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);

    ReadFile(hFile, &buffer,ReadBytes ,&dwRead ,NULL);
    I can't say for sure.....but that doesn't look work related.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Use sizeof() for the readbytes and dwRead as a check that all the data was read.
    Also catch the return of ReadFile(), has to be greater than 0 or error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM