void main()
{
int i1,i2,i3;
FILE *fp ;
fp=fopen("file.txt" , "r");
while(!feof(fp) )
{
if ( fscanf("%s %d %d %d\n" , name, &i1 , &i2,&i3 ) != 4 )
break ;
printf("%s %d %d %d\n" , name , i1,i2,i3 );
}
fclose(fp) ;
} 代码样板,你自己试一下吧
#include
#include
using namespace std;
int main()
{
filebuf Buffer;
Buffer.open("1.txt", ios::in);
cout << &Buffer;
}