Why doesn't this work in Windows Form Applications?

1
2
3
4
	void toLowerCaseSTD(String^ &str)
{
	transform(str.begin(), str.end(), str.begin(), tolower);
}


The error is this

1
2
3
Error	2	error C2228: left of '.end' must have class/struct/union	c:\users\jeremy\documents\visual studio 2010\projects\launcher\launcher\Form1.h	24
Error	5	error C2228: left of '.c_str' must have class/struct/union	c:\users\jeremy\documents\visual studio 2010\projects\launcher\launcher\Form1.h	234
Error	1	error C2228: left of '.begin' must have class/struct/union	c:\users\jeremy\documents\visual studio 2010\projects\launcher\launcher\Form1.h	24
Is there another method i can use to change uppercase letters to lower case letters in C++ windows form application? It'd be greatly appreciated. This code works fine in Console apps, just not Windows Forms apps.
Class System::String has method ToUpper that you should use.
For example in C# the corresponding code will look

1
2
3
4
string s = "This is a test";
s = s.ToUpper();

Console.WriteLine( s );
Last edited on
Actually i just used a different method but i need help with another thing...
i'm trying to convert a String^ to a const char*. Got any ideas?

So far i've tried
const char* = total1.data();

and

const char* = total1.c_str();

but the .Net framework says this

Error 1 error C2228: left of '.data' must have class/struct/union c:\users\jeremy\documents\visual studio 2010\projects\launcher\launcher\Form1.h 237

same thing for the .c_str();

DDD:
Bump
You're confusing an .Net string with a C++ stanadard string. In this instance, transform() is expecting a C++ standard string.
Okay so how would i convert a String^ to a const char*? That's my real question. Idc how it is done as long as it is done.
closed account (o1vk4iN6)
Why use microsoft's mutant version of C++ ?

Okay so how would i convert a String^ to a const char*?


If you were using std::string it would be var.c_str().
@xerzi I already knew that if you didn't read my other post i obviously stated that it doesn't work. :\

@naraku9333 I need it to be a "const char*" which that does not convert to.
Last edited on
Presumably, you could just do:
 
std::wstring wstr = PtrToStringChars(str);


... CLR. uh!
I got it to work and no that isn't how it works. Windows form apps uses the .net framework buddy.
@naraku9333 I need it to be a "const char*" which that does not convert to.
All you would need to add to the code in the link is const char* cch(ch);

Windows form apps uses the .net framework buddy.
C++ CLI can use both .Net and the std library.
Last edited on
Topic archived. No new replies allowed.