只有3个错了,哪个高手可以帮忙在DEV C++上调试成功

来源:百度知道 编辑:UC知道 时间:2024/06/03 09:10:53
很简单的一个程序,帮忙调一下...谢谢啦

从语法来讲 ,问题只有一个,函数void totle() 中的for(int i=0....),这样i且的生命周期只有在这个for语句中,而之后你还在for{}结束之后使用i,错误.
解决方法,把i的生命周期变为整个void totle()函数或,把其后的赋值移动到for语句中.
这个程序不是楼主写的吧,看时间是07年12月的
原来的调试环境应该是vc++6.0,所以才会出现这个问题,vc6.0比较老啦

还有一个不是问题的问题 就是你如此频繁的使用cin函数,那么记得在每次使用结束之后 都要加上一句cin.clear();
否则前一次的输入可能会影响到后边的结果

#include <ctime>
#include <iostream>
using namespace std;

struct SCORC
{
signed int len;
signed int wrong;
signed int right;
double time;
};

SCORC scorc={0,0,0,0.0};

static char* txt=NULL;
static char* input=NULL;

void totle()
{
scorc.right=0;
scorc.wrong=0;
int i;
for (i=0; i<scorc.len; i++)
{
if ('\0'==txt[i])
break;
if (txt[i]==input[i])
scorc.right++;
else
scorc.wrong++;

}
scorc.len=i;
}

int main()
{
cout<&