myprintf.c

来自「这是一个用OPENGL和VC++作的人工智能程序,大家可以借鉴一下」· C语言 代码 · 共 53 行

C
53
字号
/* Copyright (C) Steven Woodcock, 2000.  * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Steven Woodcock, 2000" *///*********************************************************************// Name:     myprintf.c// Purpose:  A simple debugging version of printf that dumps data//           to a text file.//*********************************************************************//// includes//#ifdef _WIN32#include <io.h>#endif#include <stdio.h>#include <stdarg.h>// globals//extern char OutputFileName[];int myprintf( char *str, ... ) {   char buf[256];   va_list vlist;   static FILE *dbg;   /* File section */   if ( dbg == NULL ) {      dbg = fopen("C:/windows/desktop/SimpleFlocking.txt", "w" );      if ( dbg == NULL ) return 0;   }   va_start( vlist, str );   vsprintf( buf, str, vlist );   va_end( vlist );   fprintf(dbg, "%s", buf );   fflush(dbg);   return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?