EOF怎样使用?
#include<iostream>#include<cstring>
const int MAX=1000;
using namespace std;
void input( char *array[],int &length)
{
length=0;
char lines[11];
while(1)
{
cin.getline(lines,11);
if(strcmp(lines,"EOF")==0) break;
array[length]=new char[strlen(lines)+1];
strcpy(array[length],lines);
length++;
}
}
void output(char *array[],int length)
{
int i;
for(i=0;i<length;i++)
{
cout<<array[i]<<endl;
delete [] array[i];
}
}
int main()
{
char *p[MAX];
int line;
input(p,line);
output(p,line);
return 1;
}
请问错在哪儿?谢谢了!