Thread: Using Windows File I/O functions

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK

    Exclamation Using Windows File I/O functions

    I've made a few programs in Windows using C now, but one thing bothers me:- the fact that I use the file I/O functions defined in stdio.h when I should be using the Win32 functions. Are they any good?

    I'd like to change my current string debug file output function:-

    int DebugCh(char *debugchar)
    	FILE *fdebug;
    	fdebug = fopen("debug.txt", "at");
    	fprintf(fdebug, "%s\n", debugchar);
    so that it uses Windows file I/O. The only thing is, there doesn't appear to be an equivalent for fprintf. Any ideas?

  2. #2
    Registered User
    Join Date
    Sep 2001
    There is no equivalent to fprintf. Either you have to run 'sprintf' or 'wsprintf' and then write the string to the file.
    // Gliptic

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    If you are using Win32Api, what you do is quite fine.
    ( you should make the char pointer 'const' though and
    check for errors ).

    If you are using the MFC, try CStdioFile and it's
    WriteString method.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Problems with file pointer in functions
    By willie in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:54 PM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM