PLCXProcess.cpp:3808:79: error: 'substr' was not declared in this scope string strpici = substr(strPLCX88Filename,strPLCX88Filename.length() - 17, 14);
时间: 2024-02-14 10:18:39 浏览: 31
这个错误提示说明在PLCXProcess.cpp文件中的第3808行,出现了一个名为'substr'的函数没有在作用域中声明的错误。
'substr'是一个string类的成员函数,用于提取字符串的子字符串。根据错误提示,很可能是string类没有被正确引用或者命名空间没有被正确指定。
你可以检查一下PLCXProcess.cpp文件中是否有string的头文件引用,或者在调用'substr'函数时是否在前面加上了std::前缀,例如std::substr。
相关问题
string strPLCX88Filename = "309910008PJB2023051903076000.o";string strpici = strPLCX88Filename.substr(strPLCX88Filename.length() - 17, 15);取出strpici是什么值
如果使用 `substr` 函数的第一个参数为 `strPLCX88Filename.length() - 17`,则表示从字符串 `strPLCX88Filename` 的倒数第 17 个字符开始取子串,而题目要求取倒数 18 位到倒数 3 位,因此应该使用 `substr` 函数的第一个参数为 `strPLCX88Filename.length() - 18`。另外,题目要求取 18 位到 3 位,因此应该使用 `substr` 函数的第二个参数为 16,而不是 15。因此,正确的代码和结果应该是:
```cpp
string strPLCX88Filename = "309910008PJB2023051903076000.o";
string strpici = strPLCX88Filename.substr(strPLCX88Filename.length() - 18, 16);
```
结果为:
```
B202305190307600
```
strPLCX88Filename=‘ 309910008PJB2023051903076000.o’;string strpici = strPLCX88Filename.substr(strfilename.length() - 18, 13);strpici是多少
在你的代码中,使用了 `strfilename` 来调用 `substr` 函数,但是变量名应该是 `strPLCX88Filename`。此外,在取子串长度时,应该是 15 而不是 13。因此,正确的代码应该是:
```cpp
string strPLCX88Filename = "309910008PJB2023051903076000.o";
string strpici = strPLCX88Filename.substr(strPLCX88Filename.length() -
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)