64,646
社区成员
发帖
与我相关
我的任务
分享
#include<iostream.h>
#include <stdio.h>
#include <fstream.h>
#define size 10
void readfile() throw(char *)
{
char *p = "data.txt";
FILE *fp;
int i = 0;
int a[size] = {0};
if (!(fp = fopen("data.txt", "r")))
{
throw("′ò?a꧰ü");
}
while(fscanf(fp, "%d", &a[i]))
{
if (i>=size)
{
break;
}
cout<<a[i]<<endl;
i++;
}
fclose(fp);
}
void main()
{
try
{
readfile();
}
catch(char *Ers)
{
cerr<<Ers<<endl;
}
}