包含与执行结果不一样,纳闷!谁能告诉我原因?
第一个程序:
#include "stdafx.h"
#include <iostream> //注意这里没有.h 与第二个程序不同
#include <fstream>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
char *sFilename = "C:\\Temp\\test1.bin";
std::fstream f;
f.open(sFilename,std::ios::in|std::ios::out|std::ios::binary);
f.seekp(0,std::ios::end);
f.write("Hello,world",12);
f.close();
return 0;
}
第二个程序:
// tst_fstream_h_01.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <iostream.h>//注意.h 与第一个程序不同
#include <fstream.h> //注意.h
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
char *sFilename = "C:\\Temp\\test2.bin";
fstream f;
f.open(sFilename,ios::in|ios::out|ios::binary);
f.seekp(0,ios::end);
f.write("Hello,world",12);
f.close();
return 0;
}