作用域中未声明的c++转换只发生在服务器上
C++ transform not declared in scope only occurs on server
我见过很多,但似乎没有一个符合我的问题。这个程序在本地运行良好,但在服务器上运行时,我遇到了一个错误。
project1.cpp:在函数' void insertwords(char*) ':Project1.cpp:54:65:错误:' transform '没有在这个作用域中声明变换(word.begin (), word.end (), word.begin()::低),
相关代码:
void insertwords(char *filename) {
ifstream fin;
fin.open(filename);
if(fin.fail())
{
cerr << "File opening failed. Exiting program.n";
exit (-1);
}
string word;
int count = 0;
while (!fin.eof() ) {
word.clear();
fin >> word;
transform(word.begin(), word.end(), word.begin(), ::tolower);
for (int i = 0, len = word.size(); i < len; i++)
{
if(ispunct(word[i]))
word.erase(i--, 1);
len = word.size();
}
if(!word.empty()) {
insert_word(word);
++count;
}
}
cout << "The number of words found in the file was " << count << "n";
fin.close();
}
包括:
#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
#include <locale>
using namespace std;
我知道使用命名空间std;这是不好的做法,但我被告知为项目
您需要#include <algorithm>
,这是std::transform
来自的标头。
至于为什么它会在一台机器上编译而不是另一台机器上,我的猜测是你的其他头文件之一(例如<string>
)包括<algorithm>
在一个编译器实现,所以你很幸运,但不是其他编译器。
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- 为 Sql 服务器实现 odbc 包装器.将数据库数据读取为字符或要求驱动程序将数据转换为 C 类型
- 使用 ESP8266/8285 将字符串从 Web 服务器转换为字节数组
- C 将NTP服务器返回的时间转换为字符串
- 无法将主机名"localhost"转换为地址:未知服务器错误
- 错误 C2664:"发送":无法将参数 2 从"服务器问候语"转换为"常量字符 *"
- 在 Web 服务器中 utf-8 和 unicode 之间进行转换
- 使用dst和boost将当前服务器时间转换为时区
- c++浮点到sql服务器DECIMAL的正确转换
- 将服务器UTC时间转换为客户端本地时间
- 如何在基于api的服务器中正确转换和使用本机COM类型
- 使用QNetworkReply,我如何发布文件,然后从服务器接收转换后的文件
- 作用域中未声明的c++转换只发生在服务器上
- 将服务器响应(std::string)转换为png文件
- 在c++流媒体服务器中使用ffmpeg转换视频
- 带有std::线程强制转换变量的c++多线程服务器
- 将我的服务器响应char数组转换为wchar_t数组是处理客户端收到的服务器消息的正确方法吗?