C programming

This is a discussion on C programming within the Windows Programming forums, part of the Platform Specific Boards category; I'm new to windows programing, I have been programming DOS in C for a while now and I was wondering ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    C programming

    I'm new to windows programing, I have been programming DOS in C for a while now and I was wondering is the code I use there vaild when programming for windows. For example if I wanted to Open and write to a file??
    OS:- XP
    Compiler:- MSVC++ 6 or DJGPP or Dev-c++ (Mingw)

  2. #2
    J.J.
    Guest
    Yes, you can use fopen and all the other "dos/console" functions which don't attempt to write to the screen. It is only the output to the screen which requires a different method.

  3. #3
    J.J.
    Guest
    For example
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int WINAPI WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int WinMode )
    {
         FILE *fp;
    
         fp = fopen( "Temp.txt", "wt" );
         fputs( "Hello World", fp );
         fclose( fp );
    
         return 0;
    }

Popular pages Recent additions subscribe to a feed

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