新微赢技术网
标题:
这个错误怎么改呀
[打印本页]
作者:
我為ぷぃ情醉
时间:
2009-11-4 01:28
标题:
这个错误怎么改呀
#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)
作者:
勇敢的心
时间:
2009-11-4 01:28
#include<iostream>
#include<fstream>
using namespace std;
void test1(const char an1[], bool & bo, ofstream & outdata);
void test2(const char an1[],bool & bo, ofstream & outdata);
void outscore(char an[],char an1[],bool bo, ofstream & outdata);
int main()
{
ifstream indata;
ofstream outdata;
indata.open("exams.txt");
outdata.open("scores.txt");
while(indata)
{
bool bo1=true;
char id[20]; // Caution
char answer[22];
indata.getline(answer,22,'\n');
indata>>id;
char answer1[30];
indata.getline(answer,30,'\n');
test1(answer1,bo1, outdata); // Caution
test2(answer1,bo1, outdata); // Caution
outscore(answer,answer1,bo1, outdata); // Caution
outdata<<endl;
}
return 0;
}
void test1(const char an1[], bool & bo, ofstream & outdata)
{
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, ofstream & outdata)
{
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, ofstream & outdata)
{
int i,count;
if(bo)
{
for(i=0;i<20;i++)
{
if(an1[i]==an[i]) // Caution
count++;
}
outdata<<count;
}
}
复制代码
作者:
太阳神
时间:
2009-11-4 01:28
谢谢了
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2