64,639
社区成员
发帖
与我相关
我的任务
分享
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main(){
ifstream infile;
infile.open("temp.txt");
int i;
if(!infile){
cout <<"This is a error!" <<endl;
abort();
}
while(!infile.eof()){
infile.read(reinterpret_cast<char*>(&i),sizeof(int));
cout <<i <<" ";
}
infile.close();
}
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main()
{
ifstream infile;
infile.open("temp.txt");
char ch;
if(!infile){
cout <<"This is a error!" <<endl;
return;
}
while(!infile.eof()){
infile.read(&ch,sizeof(char));
cout <<(int)ch <<" ";
}
infile.close();
}