Hello,
i don't manage to use the tolower() function:
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
using std::cout;
using std::ctype;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::use_facet;
typedef ctype< char > char_ctype_face t;
int
main()
{
locale loc("");
const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc);
string str("Hello world.");
transform(str.b egin(), str.end(),
str.begin(), ct.tolower);
cout << str << endl;
return 0;
}
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc
tolower.cc: In function `int main()':
tolower.cc:24: error: no matching function for call to
`transform(__gn u_cxx::__normal _iterator<char* , std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >,
__gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char,
std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
--
TheDD 11 3363
TheDD wrote: Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_face t;
int main() { locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.b egin(), str.end(), str.begin(), tolower);
do the trick? cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gn u_cxx::__normal _iterator<char* , std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, __gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, __gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
Not sure.
Victor
Victor Bazarov wrote: [...] locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.b egin(), str.end(), str.begin(), tolower);
do the trick?
yes it does, thx a lot.
But in this case, i guess the used locale is "C". What can i do to use
another one?
--
TheDD
TheDD wrote: Victor Bazarov wrote:
[...]
locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
Wouldn't
transform(str.b egin(), str.end(), str.begin(), tolower);
do the trick?
yes it does, thx a lot.
But in this case, i guess the used locale is "C". What can i do to use another one?
Good question. Could you temporarily set it as "global one to use"
somehow? I am not that familiar with locales, as you probably figured
out by now...
V
Victor Bazarov wrote: Good question. Could you temporarily set it as "global one to use" somehow? I am not that familiar with locales, as you probably figured out by now...
Well i can use:
locale::global( locale(""));
but it's not really great. I'm going to read the docs one more time :)
--
TheDD
TheDD wrote: i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_face t;
int main() { locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
If you have to use a member function, try something like
std::transform( str.begin(), str.end(), str.begin(),
std::bind1st(st d::mem_fun(&cty pe<char>::tolow er), ct));
I couldn't get it to compile, but dig in that direction. cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24: error: no matching function for call to `transform(__gn u_cxx::__normal _iterator<char* , std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, __gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, __gnu_cxx::__no rmal_iterator<c har*, std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
To use a member function, you need 'mem_fun'.
Victor
On Fri, 28 May 2004 22:18:50 +0200, TheDD <pa*********@pa s.de.spam.fr>
wrote: Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
#include <cstdlib> using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_face t;
int main() { locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:2 4: error: no matching function for call to `transform(__g nu_cxx::__norma l_iterator<char *, std::basic_stri ng<char, std::char_trai ts<char>, std::allocator< char> > >, __gnu_cxx::__n ormal_iterator< char*, std::basic_stri ng<char, std::char_trai ts<char>, std::allocator< char> > >, __gnu_cxx::__n ormal_iterator< char*, std::basic_stri ng<char, std::char_trai ts<char>, std::allocator< char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
You need to include a library that includes tolower.
rossum
(Who has done the same sort of thing more often than he cares to
remember.)
--
The Ultimate Truth is that there is no Ultimate Truth
Le 28/05/2004 à 23:29:31, rossum <ro******@coldm ail.com> a écrit: On Fri, 28 May 2004 22:18:50 +0200, TheDD <pa*********@pa s.de.spam.fr> wrote:
Hello,
i don't manage to use the tolower() function:
#include <algorithm> #include <iostream> #include <locale> #include <string>
#include <cstdlib>
using std::cout; using std::ctype; using std::endl; using std::locale; using std::string; using std::transform; using std::use_facet;
typedef ctype< char > char_ctype_face t;
int main() { locale loc(""); const char_ctype_face t& ct = use_facet< char_ctype_face t >(loc); string str("Hello world.");
transform(str.b egin(), str.end(), str.begin(), ct.tolower);
cout << str << endl; return 0; }
$ g++ -W -Wall -std=c++98 -pedantic tolower.cc tolower.cc: In function `int main()': tolower.cc:24 : error: no matching function for call to `transform(__ gnu_cxx::__norm al_iterator<cha r*, std::basic_stri ng<char, std::char_tra its<char>, std::allocator< char> > >, __gnu_cxx::__ normal_iterator <char*, std::basic_stri ng<char, std::char_tra its<char>, std::allocator< char> > >, __gnu_cxx::__ normal_iterator <char*, std::basic_stri ng<char, std::char_tra its<char>, std::allocator< char> > >, <unknown type>)'
ct.tolower is <unknow type>
What am i doing wrong?
You need to include a library that includes tolower.
rossum (Who has done the same sort of thing more often than he cares to remember.)
same error message, doesn't seem to be that.
--
TheDD
Victor Bazarov wrote: If you have to use a member function, try something like
std::transform( str.begin(), str.end(), str.begin(), std::bind1st(st d::mem_fun(&cty pe<char>::tolow er), ct));
I couldn't get it to compile, but dig in that direction.
Well i don't have a member function.
This works:
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <functional>
using std::cout;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::bind2nd;
struct s : std::binary_fun ction< char, locale, char >
{
char operator ()(char c, const locale & loc) const
{
/* use:
* template<typena me CharT>
* CharT std::tolower ( CharT c,
* const locale & __loc
* )
*/
return std::tolower(c, loc);
}
};
int
main()
{
locale loc("");
string str("Hello world.");
// use s operator ()
transform(str.b egin(), str.end(),
str.begin(), bind2nd(s(), loc));
cout << str << endl;
return 0;
}
but is really not classy.
--
TheDD
"TheDD" <pa*********@pa s.de.spam.fr> wrote... Victor Bazarov wrote:
If you have to use a member function, try something like
std::transform( str.begin(), str.end(), str.begin(), std::bind1st(st d::mem_fun(&cty pe<char>::tolow er), ct));
I couldn't get it to compile, but dig in that direction.
Well i don't have a member function.
If you didn't, why were you trying to say
ct.tolower
? Isn't the notation '.' meant for member access? I must
be missing something here...
V This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: qazmlp |
last post by:
I was using the following code to convert the string to
lowercase.
string foo = "Some Mixed Case Text";
transform(foo.begin(), foo.end(), foo.begin(), tolower);
I thought the above code is portable.
But, the following page has a different view on this:
http://lists.debian.org/debian-gcc/2002/debian-gcc-200204/msg00092.html
|
by: David Rubin |
last post by:
I get an error when I compile the following code:
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
string&
|
by: Ahsan |
last post by:
Hi All,
I am having prolems with converting upper case characters to lower
case in Unix's C. I saw the man pages and "tolower" function does it.
But in my case its not working.
My code is as follows:
============================================================
gets ( input );
sscanf(input, "%s", Cmd);
for( p = 0; p < strlen( Cmd ); p++ )/* Changing all input to lower
|
by: Daniel Aarno |
last post by:
As far as I can tell the locale header should provide a tolower function
however the following failes for me under gcc 3.4.
transform(begin, end, begin2, std::tolower);
with an error that the last arg is of unknown type. Any ideas on why?
|
by: Eric Lilja |
last post by:
Hello, consider this program:
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
int
main()
{
std::string s = "HEJ";
| |
by: Ben Dewey |
last post by:
Project:
----------------------------
I am creating a HTTPS File Transfer App using ASP.NET and C#. I am
utilizing ActiveDirectory and windows security to manage the
permissions. Why reinvent the wheel, right? Everything so far is
working well with the Active Directory. The problem I am having is
with adding File Permissions to a directory. I am currently using
some code courtesy of "Willy Denoyette "
|
by: Anthony Williams |
last post by:
Hi gang,
This one looks like a bug :o(
As you may or may not know, setting session management in web.config to use
cookieless sessions causes the ASP.NET runtime to munge a session ID into
the URL, in the format http://yourapplicationpath/(Session.SessionID)/...
which saves numerous headaches when it comes to storing state across page
requests and sessions.
|
by: Faray |
last post by:
Hello, this is my first post, so hopefully I am posting this in the right place.
Hopefully someone will be able to help me out with my problem here it is:
I need to make a program that ask a user to input a word. However when they input that word I need to convert the word to all lowercase letters so it can do a serach. This is my problem:
Every time I try to use tolower it gives me an error
"Cannot convert parameter 1 from...
|
by: Soumen |
last post by:
I wanted convert a mixed case string to a lower case one. And I tried
following code:
std::transform(mixedCaseString.begin(), mixedCaseString::end(),
mixedCaseString.begin(), std::ptr_fun(tolower));
Even though I's including cctype and algorithm, I's getting compiler (g
++ 3.3.6) error:
no matching function for call to `ptr_fun(<unknown type>)'
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |