在用vs写win32的c++程序时是没有命令行的,所以printf是不能用的。
但是调试的时候可以调用函数OutputDebugString来想vs的“输出”窗口里输出调试内容。像java中的System.out.println一样往IDE的调试窗口里输出信息。
OutputDebugString只接受字符串指针,如果要输出其他格式,如int型,可以用sprintf把字符转成字符串,在传给OutputDebugString。
例子:
char chInput[512] ; sprintf(chInput,"int:%d\n",500); OutputDebugString( chInput );