PDA

View Full Version : Quick question regarding strings and toupper...


abbeyroadd
03-04-2005, 03:55 PM
Using VS .NET 2003 I have this function:


// Function to assist find when searching for an item by it's specific name.
void choosename(DynArray<Item>&array, string temp, int num)
{
for (int i = 0; i < num; ++i)
{
if (array[i].name == temp)
{
cout << array[i].name << '\t' << array[i].type << '\t' << array[i].cost << '\t' << array[i].weight << '\n';
return;
}
}
cout << "We don't have that!\n";
}

The only thing is that the output will be correct if the name is typed in the exact case. So I want to use toupper on the temp string being passed into the function so the name can be typed in anyway...I have tried using transform:

transform(temp.begin(), temp.end(), temp.begin(), toupper);

But that didn't work...if anyone has any ideas I would really appreciate it.

Thank you.

aman
03-04-2005, 05:33 PM
It works for me.. I'm not using .NET though.. sorry.

You might have to just loop through the characters yourself and convert them. :/