错误: 对‘tolower(std::basic_string<char, std::char_traits<char

软件和网站开发以及相关技术探讨
回复
头像
anapple
帖子: 21
注册时间: 2008-09-20 12:20

错误: 对‘tolower(std::basic_string<char, std::char_traits<char

#1

帖子 anapple » 2008-10-06 11:27

下面是我的程序:麻烦请指点出错误!

#include <iostream>
#include <string>
#include <vector>
//#include <conio.h>
#include <ctype.h>
using std::vector;
using std::string;
using std::cin;
using std::cout;
using std::endl;
int main ()
{
string text;
vector <string> vstr;
while (cin >> text)
{
if (text == "quit")
return -1;
//else if (text == "enter")
//getch(void);
else
vstr.push_back(text);

}
/*for (vector<string>::size_type cut=0; cut != vstr.size(); ++ cut)
{
cout <<"原来的形式"<< vstr[cut] ;
//int cout=1;
//cout++;

//if(cout/8 == 0)
//cout << endl;

} */

for ( vector<string>::size_type cut=0; cut != vstr.size(); ++ cut)
{
vstr[cut]=tolower(vstr[cut]);
cout <<"改变的形式"<< vstr[cut];
//int cout=1;
//cout++;

//if(cout/8 == 0)
//cout << endl;

}


提示的错误为:

314.cc:68: 错误: 对‘tolower(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’的调用没有匹配的函数
/usr/include/ctype.h:116: 附注: 备选为: int tolower(int)

还请帮我指出点眉目。小弟刚学,很菜!谢谢了。

小弟还有个问题。
include 引用的文件是放在哪里阿。比如《string》阿
头像
anapple
帖子: 21
注册时间: 2008-09-20 12:20

Re: 错误: 对‘tolower(std::basic_string<char, std::char_traits<char

#2

帖子 anapple » 2008-10-07 13:59

我看了答案节结了,

我还是没有明白为什么要这样。像二维数组一样。希望明白的朋友指点一下哦。

for(vector<string>::size_type ix=0;ix!=text.size();++ix)

for(vector<string>::size_type ix2=0;ix2!=text[ix].size();++ix2)

text[ix][ix2]=tolower(text[ix][ix2]);
回复