类型字符串::长度()。我得到了"Unable to resolve identifier length"
Typed string::length(). I got "Unable to resolve identifier length"
使用 Win8.1 系统。使用 NetBeans IDE 进行C++编程,因为它提供了一种制作简单窗口的简单方法。
法典:
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
int main(int argc, char** argv) {
srand(time(NULL));
int seed_component0 = rand();
string Player_name;
string seed_component1;
int i = 0;
cout << "Please, enter your player name: ";
cin >> Player_name;
while (i < Player_name.length()){
seed_component1.append(int(Player_name[i]));
i++;
}
string seed = seed_component0 + seed_component1;
cout << endl << "The seed we will use is " << seed << endl;
return 0;
}
这只是主文件,我只创建了一个新项目并尝试这样做,但是当我尝试运行它时,它抛出了"无法解析标识符长度" 我也尝试了 size((。它只是不知道那是什么。
此外,我还有另一个不影响程序的错误,至少目前是这样;在包含行中,它说"库文件(路径(,但在包含的文件(路径(wctype.h中有一个未解析的 #include
我正在使用MinGW作为编译器。
编辑:我也想使用to_string((,但它也不起作用。
我尝试使用 sstream 而不是 to_string(( 进行转换。我还用 for 循环替换了你的 while 循环。大小((虽然对我有用
只需看一下 http://www.cplusplus.com/articles/D9j2Nwbp/这是关于将数字转换为字符串,反之亦然
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
using namespace std;
string IntToString(int Number)
{
ostringstream ss;
ss << Number;
return ss.str();
}
int main(int argc, char** argv) {
srand(time(NULL));
int seed_component0 = rand();
string Player_name;
string seed_component1;
int i = 0;
cout << "Please, enter your player name: ";
cin >> Player_name;
int name_length = Player_name.size();
for(int i = 0; i < name_length; i++)
{
seed_component1 += IntToString(int(Player_name[i]));
}
string seed = IntToString(seed_component0) + seed_component1;
cout << endl << "The seed we will use is " << seed << endl;
return 0;
}
将 C 和 C++ 都设置为版本 11 有助于解决"无法解决 length(("问题。尚未尝试秒C++ v14 或 v17
相关文章:
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- Win32 API - HWND "{unused = ???} Unable to read memory"错误
- 从生成文件编译错误:"Unable to open output file" ..."No such file or directory"
- 如何在qt中修复"No query Unable to fetch row"
- 类型字符串::长度()。我得到了"Unable to resolve identifier length"
- Qt应用程序中的"No query Unable to fetch row"
- 如何处理"Cmake Error: Unable to find the requested Boost libraries"?
- MSVC:带函数的"error C2244: unable to match function definition to an existing declaration"是指专用模板类的类型别名
- 使用 Korge 编译本机时"Unable to find library"抛出错误
- QNetwork回复 "unable to write"
- AWS 批处理"unable to connect to endpoint"
- 仅在一台计算机上出现"0xc000007b Application Unable to Start Correctly"错误
- "Unable to open file libc++abi.dylib" .程序生成,但在运行时崩溃。使用 xcode 10.1 (10B61)
- 调用 QSqlTableModel setTable 方法时出现"Unable to find table"错误
- 为什么 void 排序(int *[], int) 会导致"Unable to read memory"?
- 如何设置Visual Studio来调试DLL ("Unable to start program error")
- PCC-S-02015, "unable to open include file"
- 在 exiv2 中"unable to parse" IPTC 日期到 XMP 日期时间
- "Unable to resolve template based identifier X" - 从模板类调用模板参数类的方法 (C++)
- AWS S3 aws-sdk-cpp GetObject "Unable to connect to endpoint"