找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 737|回复: 2

这个错误怎么改呀

[复制链接]
发表于 2009-11-4 01:28:20 | 显示全部楼层 |阅读模式 IP:江苏扬州
#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:22 | 显示全部楼层 IP:江苏扬州
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;

  4. void test1(const char an1[], bool & bo, ofstream & outdata);
  5. void test2(const char an1[],bool & bo, ofstream & outdata);
  6. void outscore(char an[],char an1[],bool bo, ofstream & outdata);

  7. int main()
  8. {
  9. ifstream indata;
  10. ofstream outdata;

  11. indata.open("exams.txt");
  12. outdata.open("scores.txt");

  13. while(indata)
  14. {
  15. bool bo1=true;
  16. char id[20]; // Caution
  17. char answer[22];
  18. indata.getline(answer,22,'\n');
  19. indata>>id;
  20. char answer1[30];
  21. indata.getline(answer,30,'\n');
  22. test1(answer1,bo1, outdata); // Caution
  23. test2(answer1,bo1, outdata); // Caution
  24. outscore(answer,answer1,bo1, outdata); // Caution
  25. outdata<<endl;
  26. }
  27. return 0;
  28. }

  29. void test1(const char an1[], bool & bo, ofstream & outdata)
  30. {
  31. int i,count=0;
  32. for(i=0;i<30;i++)
  33. while(an1[i]!='\0')
  34. count++;
  35. if(count<20)
  36. {
  37. outdata<<"Too few answers ";
  38. bo=false;
  39. }

  40. if(count>20)
  41. {
  42. outdata<<"Too many answers ";
  43. bo=false;
  44. }
  45. }

  46. void test2(const char an1[],bool & bo, ofstream & outdata)
  47. {
  48. int i;
  49. for(i=0;i<30;i++)
  50. while(an1[i]!='\0')
  51. while(!(an1[i]>=97&&an1[i]))
  52. {
  53. outdata<<"Invalid answers ";
  54. bo=false;
  55. }
  56. }

  57. void outscore(char an[],char an1[],bool bo, ofstream & outdata)
  58. {
  59. int i,count;
  60. if(bo)
  61. {
  62. for(i=0;i<20;i++)
  63. {
  64. if(an1[i]==an[i]) // Caution
  65. count++;
  66. }
  67. outdata<<count;
  68. }
  69. }

复制代码
回复

使用道具 举报

发表于 2009-11-4 01:28:22 | 显示全部楼层 IP:江苏扬州
谢谢了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 03:24 , Processed in 0.210405 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表