运行我的程序时不断收到此错误。如果我删除无效函数它工作正常,但是当我尝试运行完整的程序时,它给了我表达:(无符号)(c + 1)< = 256错误。尝试了一些在这个网站的线程来弄清楚发生了什么,但仍然无法弄清楚(Something,一些未签名的字符?)。我是初学者,所以任何帮助将不胜感激。这是我到目前为止:表达式:(无符号)(c + 1)<= 256?
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
void countUpperLower(ifstream& instream, ofstream& outstream);
void Convert(ifstream& in_stream, ofstream& out_stream);
int main()
{
ifstream fin;
ofstream fout;
fin.open("CAD.dat");
if (fin.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open("outputs.txt");
if (fout.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
countUpperLower(fin, fout);
Convert(fin, fout);
fin.close();
fout.close();
cout << endl << "End of editing files.\n";
return 0;
}
void countUpperLower(ifstream& instream, ofstream& outstream)
{
char caps;
int uppercase = 0;
int lowercase = 0;
do
{
instream.get(caps);
if (isupper(caps))
uppercase++;
else if (islower(caps))
lowercase++;
} while (caps != '.');
cout << "There are " << uppercase << " uppercase letters in this file\n";
cout << "There are " << lowercase << " lowercase letters in this file\n";
}
void Convert(ifstream& in_stream, ofstream& out_stream)
{
char next;
do
{
in_stream.get(next);
if (isspace(next))
cout << '-';
else if (isdigit(next))
cout << '#';
else if (isupper(next))
putchar (tolower(next));
else if (islower(next))
putchar (toupper(next));
else
cout << next;
} while (next != '.');
}
什么是*确切*,*完整*错误信息?你的代码中没有叫'c'的变量。 – 2014-11-01 18:45:27
弹出一个对话框,并说:调试断言失败!程序:... /作业6.exe文件:f:\ dd \ vctools \ crt_bld \ self_x86crt \ src \ isctpye.c行:56表达式:(unsigned)(c + 1)<= 256 – Kramer 2014-11-01 18:47:56
另外,当我运行该程序与CTRL + F5没有编译器错误。 – Kramer 2014-11-01 18:59:49