What are the API equ. of getchar and putchar? Heres the code I'm trying to translate:

#include        
#include        
#define         DEC(c)  (char)(((c)-' ')&077)

int main()
{
      int     n;
      char    buf[128],a,b,c,d;

      scanf("begin %o ", &n);
      gets(buf);                              /* filename */
      if (!freopen(buf, "wb", stdout))         /* oops.. */
      {
            perror(buf);
            exit(1);
      }
      while ((n=getchar())!=EOF&&((n=DEC(n))!=0))
      {
            while (n>0)
            {
                  a=DEC(getchar());
                  b=DEC(getchar());
                  c=DEC(getchar());
                  d=DEC(getchar());
                  if (n-->0)
                        putchar((a<<2)|(b>>4));
                  if (n-->0)
                        putchar((b<<4)|(c>>2));
                  if (n-->0)
                        putchar((c<<6)|d);
            }
            n=getchar();                    /* skip \n */
      }
      return 0;
}
Xtreme
Posted on 2001-03-14 07:07:00 by xtreme
the program you've listed is reading from one file and writing to another, if you want to use pipes and things you can use GetStdHandle to retrieve the handles for input and output, then use ReadFile and WriteFile to write to them.... Windows is a funny beast, all that stdio stuff from C only works in C... Umbongo
Posted on 2001-03-14 07:34:00 by umbongo
getchar() and putchar() are byte read and write commands. I havent done this in Win32 as of yet, but i see no reason why this wont work: [ Getchar() ] invoke WriteFile, hFileW, addr ofAByte, 1, addr BytesWritten, NULL [ Putchar() ] invoke ReadFile, hFileR, addr toStoreByte, 1, addr BytesRead, NULL BytesWritten and BytesRead can be the same location, they are just feedback from the API... This assumes you have created separate hFileW and hFileR file handles... Make macros out of these and call them Getchar and Putchar if you would like :) NaN This message was edited by NaN, on 3/14/2001 10:05:13 AM
Posted on 2001-03-14 09:01:00 by NaN
If you are still interested using those C functions, please check out CRTDLL.DLL. It contains all those C runtime library functions. So it is one on one translation between C and ASM. There is no header (CRTDLL.INC) available. Needless to say, they are implemented using Win32 api internally. Jones.
Posted on 2001-03-14 10:41:00 by sjhenry