Command Prompt for Windows

Stdin, Stdout and Stderr

The standard I/O streams stdin, stdout and stderr are not supported by the External Command SDK. Instead the SDK provides a number of functions that attempt to simulate these streams. Functions that requires stdin, stdout or stderr to be past as a parameter will NOT work, and should NOT be used. For example, fputc(c, stdout), putc(c, stdout), fgetc(stdin) or getc(stdin) should not be used. When a program uses these functions, the program will still compile and run, but will not produce the expected result. You may very well be wondering what happens when a program uses these functions, well, the output will most likely end up writing over the desktop window. The SDK supports the following functions, which attempt to mimic the standard I/O functions of the same name as closely as possible :-

printf putchar textcolor scrwidth perror
scanf getchar clrscr scrheight  
putx putch clreol wherex  
gets getch gotoxy wherey  

Actually, stdin, stdout and stderr is a special case of a much larger problem. In general, it is not recommended to use any functions from the standard I/O library that uses buffered I/O or file streams (ie. FILE *stream). For example fopen(), fread(), fwrite(), fclose(), fprintf(), etc..., should not be used, instead un-buffered file I/O should be used, for example open(), close(), read(), write(), OpenFile(), CreateFile(), etc... Un-buffered file I/O will allow yield points to be inserted into the code, so that other tasks can run.