例如,我有一个测试文件,在对istream :: get()的4次调用之后,包含À¿。我得到了(已广播的)值195、128、195,但是我也得到了-65 -62这类的值,不在文件中。如何避免这些垃圾值?测试文件包含以下内容:ÀÀ¿
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <fstream>
using namespace std;
int main()
{
unsigned int s = 0;
char c;
vector<unsigned int> v;
ifstream is ("test.txt");
is.seekg(0,is.end);
int length = is.tellg();
is.seekg(0,is.beg);
int i = 0;
cout<<length<<endl;
while(i < length/2){
is.get(c);
i++;
cout<<(int)c;
}
return 0;
}
例如,我有一个测试文件,在对istream :: get()的4次调用之后,包含À¿。我得到了(已广播的)值195、128、195,但是我也得到了-65 -62这类的值,不在文件中。如何...