变量a等于多少?

下面的代码:

#include <fstream>
#include <sstream>
#include <string>
using namespace std;

int main()
{
	int a = 100;
	ifstream fIn;
	fIn.open("test.dat");
	stringstream strStream;
	string str;
	getline(fIn, str);
	strStream << str;
	strStream >> hex >> a;
	fIn.close();
	return 0;
}

如果没有文件test.dat时,a的值是多少呢?
a = 100,因为没有文件的时候,strStream为空,不会写入变量a中任何值。

posted @ 2015-12-02 00:22  dflyingfish  阅读(243)  评论(0)    收藏  举报