我想用一个FormatCString.h 和FormatCString.cpp
把字符串格式化封装 , 
FormatCString.h
////////
#ifndef __HB_FORMATCSTRING__
#define __HB_FORMATCSTRING__TCHAR *  CDECL FormatCString (TCHAR * szFormat, ...) ;#endif __HB_FORMATCSTRING__
/////////
FormatCString.cpp
///////
#include "FormatCString.h"TCHAR *  CDECL FormatCString (TCHAR * szFormat, ...)
{
     static TCHAR  szBuffer[1024]  ;
     va_list pArgList ;          // The va_start macro (defined in STDARG.H) is usually equivalent to:
          // pArgList = (char *) &szFormat + sizeof (szFormat) ;     va_start(pArgList, szFormat) ;          // The last argument to wvsprintf points to the arguments     _vsntprintf (szBuffer, sizeof (szBuffer) / sizeof (TCHAR), 
                  szFormat, pArgList) ;          // The va_end macro just zeroes out pArgList for no good reason     va_end (pArgList)  ;     return szBuffer ;
}
//////////
出现了
fatal error c1010:在查找预编译头指令时遇到的文件结尾求助呀!急!

解决方案 »

  1.   

    在你的 .cpp 中 #include "stdafx.h"
      

  2.   

    谢谢了!搞定了,但是为什么要加 #include "stdafx.h"呢?
      

  3.   

    因为#include "stdafx.h"包含了一系列的操作字符串所必须的头文件.
      

  4.   

    stdafx.h 是预处理头文件,是被预先编译的部分,如果有用到相应的接口都是要包含它的
    你也可以不采用预处理头文件,方法是:
    Project -> Settings -> C++ -> Precompiled headers -> Not using precompiled headers