C++ 错误:';CLSS&x27;是否未在此范围内声明?
为什么我的函数“CSS()”不能在此代码中工作,错误是:C++ 错误:';CLSS&x27;是否未在此范围内声明?,c++,C++,为什么我的函数“CSS()”不能在此代码中工作,错误是: C:\Users\KEstudio\Desktop\Programming\Learning C++ resources\projects\homework saver\main.cpp||In function 'int main()':| C:\Users\KEstudio\Desktop\Programming\Learning C++ resources\projects\homework saver\main.cp
C:\Users\KEstudio\Desktop\Programming\Learning C++ resources\projects\homework saver\main.cpp||In function 'int main()':|
C:\Users\KEstudio\Desktop\Programming\Learning C++ resources\projects\homework saver\main.cpp|20|error: 'CLSS' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|
这是我的密码:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
void ClSS()
{
system("CLS");
}
const char* CTS(string);
int main()
{
A:
string HWS, HW;//We will be saving our input in this
cout << "Please enter the homework subject:" << endl;
getline(cin, HWS);
CLSS();
cout << "Please enter the homework:" << endl;
getline(cin, HW);
CLSS();
ofstream myfile;
myfile.open(CTS(HWS+".txt"));
myfile << HW;
myfile.close();
cout << "You have saved the information to a file! :D" << endl;
string SEL;
bool ASEL=false;
cout << "Do you wan't to add another entry? yes or no" << endl;
getline(cin, SEL);
system("CLS");
if(SEL=="yes" || SEL=="Yes" || SEL=="YES" || SEL=="Y" || SEL=="y")
ASEL=true;
else
ASEL=false;
if(ASEL==true)
goto A;
return 0;
}
const char* CTS(string strng)
{
const char* FON;
FON=strng.c_str();
return FON;
}
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
void ClSS()
{
系统(“CLS”);
}
常量字符*CTS(字符串);
int main()
{
A:
字符串HWS,HW;//我们将在这个
您可能已经声明了ClSS()
,但是您正在调用ClSS())
。后者没有在任何地方声明。谢谢,我一定花了20多分钟寻找错误,几乎发疯了,我知道了。很简单:P@user2003618区分大小写的搜索非常有用。注意:您的CTS
函数具有未定义的行为,返回指向本地std::str的内部缓冲区的指针ing
。