ToUpper and ToLower part of a string in .net C++?
-
Thanks for looking at my question, I am wondering how I would use the ToUpper and ToLower functions on only part of a string in .net C++. For example, I converted an inputted name to all caps for the purpose of comparing it. Now I need to display the name with only the first letter capitalized. In short, I need to make "BRAD" to "Brad" Note that the inputted name is not always the same, so however you can show me how to do this has to work with any inputted name. Thanks for any help!!
-
Thanks for looking at my question, I am wondering how I would use the ToUpper and ToLower functions on only part of a string in .net C++. For example, I converted an inputted name to all caps for the purpose of comparing it. Now I need to display the name with only the first letter capitalized. In short, I need to make "BRAD" to "Brad" Note that the inputted name is not always the same, so however you can show me how to do this has to work with any inputted name. Thanks for any help!!
TabascoSauce wrote:
.net C++
Are you talking about the C++ that uses System::String? If so, there's a forum[^] just for that variant of C++ (and it's not this one). In general, though, you'd identify the sub-string that you want to convert, extract if from the string, convert it and then re-insert it into the string. HTH! [edit]In MFC, I'd do it like this:
CString CapitaliseName(CString const& upperCaseName)
{
return upperCaseName.Left(1) + upperCaseName.Mid(1).MakeLower();
}[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
TabascoSauce wrote:
.net C++
Are you talking about the C++ that uses System::String? If so, there's a forum[^] just for that variant of C++ (and it's not this one). In general, though, you'd identify the sub-string that you want to convert, extract if from the string, convert it and then re-insert it into the string. HTH! [edit]In MFC, I'd do it like this:
CString CapitaliseName(CString const& upperCaseName)
{
return upperCaseName.Left(1) + upperCaseName.Mid(1).MakeLower();
}[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Thanks for the help, sorry about the wrong forum, I'll repost there.
-
Thanks for the help, sorry about the wrong forum, I'll repost there.
TabascoSauce wrote:
sorry about the wrong forum
No problem - BTW - have a look at the
System::String
docs - I have a feeling you'll find the same methods on that as I used on the MFCCString
class....Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p