#include<iostream>
#include<fstream>
void test1(const char an1[],bool&bo);
void test2(const char an1[],bool&bo);
void outscore(char an[],char an1[],bool bo);
using namespace std;
int main()
{
ifstream indata;
ofstream outdata;
indata.open("exams.txt");
outdata.open("scores.txt");
while(indata)
{
bool bo1=true;
char*id;
char answer[22];
indata.getline(answer,22,'\n');
indata>>id;
char answer1[30];
indata.getline(answer,30,'\n');
test1(answer1,bo1);
test2(answer1,bo1);
outscore(answer,answer1,bo1);
outdata<<endl;
}
return 0;
}
void test1(const char an1[],bool&bo)
{
int i,count=0;
for(i=0;i<30;i++)
while(an1[i]!='\0')
count++;
if(count<20)
{
outdata<<"Too few answers ";
bo=false;
}
if(count>20)
{
outdata<<"Too many answers ";
bo=false;
}
}
void test2(const char an1[],bool&bo)
{
int i;
for(i=0;i<30;i++)
while(an1[i]!='\0')
while(!(an1[i]>=97&&an1[i]))
{
outdata<<"Invalid answers ";
bo=false;
}
}
void outscore(char an[],char an1[],bool bo)
{
int i,count;
if(bo)
{
for(i=0;i<20;i++)
{
if(an1[i]=an[i])
count++;
}
outdata<<count;
}
}
编译时出错 怎么也想不痛,各位大虾多多指点
--------------------Configuration: chapter7 - Win32 Debug--------------------
Compiling...
c.cpp
E:\temp\chapter7\c.cpp(41) : error C2065: 'outdata' : undeclared identifier
E:\temp\chapter7\c.cpp(41) : error C2297: '<<' : illegal, right operand has type 'char [18]'
E:\temp\chapter7\c.cpp(46) : error C2297: '<<' : illegal, right operand has type 'char [18]'
E:\temp\chapter7\c.cpp(57) : error C2297: '<<' : illegal, right operand has type 'char [18]'
E:\temp\chapter7\c.cpp(71) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
Error executing cl.exe.
chapter7.exe - 4 error(s), 1 warning(s)