delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/08/12/22:43:18

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Thu, 12 Aug 99 19:42:11 PDT
From: jim AT nga DOT com (Jim Roy)
Message-Id: <9908130242.AA22543@nga.nga.com>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: freopen() problems

The following code works on at least one persons system.
On mine, the freopen() call for one stream wipes out the other.
If I uncomment the second pair, all the reads/writes work fine.

This is a win98 system.
I'v upgraded to 2.95 versions of gcc and mingw-extras
I'm not geting the cygwin.dll by mistake.
I'm using -mwindows, and -mno-cygwin.

I'm at my wits end.  
I will be most grateful for ideas about what's left to double check?

----- Begin Included Message -----


#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

main (argc, argv)
int argc;
char *argv[];

{
  char answer[80];
  HANDLE handlein, handleout;

  handlein = GetStdHandle (STD_INPUT_HANDLE);
  handleout = GetStdHandle (STD_OUTPUT_HANDLE);
  
  if (handleout == INVALID_HANDLE_VALUE)
    {
      AllocConsole ();
    }

  freopen ("CONOUT$", "w", stdout);
  printf(  "Thanks Tor\n" );

  freopen ("CONIN$", "r", stdin);
  fscanf( stdin, "%s", answer );

  /*  freopen ("CONOUT$", "w", stdout); */
  fprintf(  stdout, "%s\n", answer);

  /* freopen ("CONIN$", "r", stdin); */
  fscanf( stdin, "%s", answer );

  fprintf(  stdout, "%s\n", answer);
  while(1);  
}

int _stdcall
WinMain (HANDLE hInstance, HANDLE hPrevInstance, char *lpszCmdLine, int nCmdShow)
{
  return main (__argc, __argv);
}


----- End Included Message -----


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019