📄 redir.c
字号:
/*
FILE : REDIR.C
Implementation of a printf redirector.
(C) C. Valens
Created : 21/09/1999
Last update : 23/09/1999
*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
static const char *redir_default = "CON";
static FILE *outstream = NULL;
int redir_open(const char *what, const char *how)
{
char str1[128], str2[10];
if (what) {
strcpy(str1,what);
}
else {
strcpy(str1,redir_default);
}
if (how) {
strcpy(str2,how);
}
else {
strcpy(str2,"w");
}
if ((outstream=fopen(str1,str2))==NULL) {
fprintf(stderr,"ERROR (redir_open) : could not open output stream.\n");
return -1;
}
return 0;
}
int redir_close(void)
{
fclose(outstream);
return 0;
}
int redir_printf(const char *format, ...)
{
/*
* Declare other local variables here.
*/
int count;
va_list ap;
va_start(ap,format);
count = vfprintf(outstream,format,ap);
fflush(outstream);
va_end(ap);
return count;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -