home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter4 / 4-4 / ConsPuts.c
Encoding:
C/C++ Source or Header  |  2000-07-17  |  493 b   |  30 lines

  1.  
  2. #include <windows.h>
  3.  
  4.  
  5. //
  6. // ConsPuts:
  7. //    Print a string to StdOut on the console
  8. //
  9. int ConsPuts(char *pszString)
  10. {
  11.     DWORD nLen = strlen(pszString);
  12.     DWORD nWritten;
  13.     HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
  14.     BOOL bRet;
  15.  
  16.     bRet = WriteConsole(hOutput, pszString, nLen, &nWritten, NULL);
  17.     return (!bRet || (nWritten != nLen)) ? 0 : nLen;
  18. }
  19.  
  20.  
  21.  
  22. int main(int argc, char *argv[])
  23. {
  24.     ConsPuts("Welcome to the your first console program.\r\n");
  25.     return 0;
  26. }
  27.  
  28.  
  29.  
  30.