_strupr

Started by
1 comment, last by mrtie_dye 20 years, 11 months ago
from a post long, long ago .....
quote: Instead of doing your own DoUCase..... you can use _strupr(press) and continue.....
I was using the following to convert a string to uppercase letters
      

DoUcasePress(char press[])
{
	int a;
	for (a = 0; a < strlen(press); a++)
	{
		press[a] = (toupper(press[a]));
	}
	return press[strlen(press)];
}

      
Now that I have grown a little, I tried to use _strupr(press) When I do, it complains "Function '_strupr' should have a prototype in function blahblah()" What header file is needed for _strupr ? [edited by - mrtie_dye on May 26, 2003 11:13:40 PM]
Marriage is the #1 cause of divorce
Advertisement
#include <string.h>

But as far as I know, it''s a Windows-only function.

If you''re using C++, try the STL :

#include <string>#include <algorithm>std::string DoUcasePress( char press[] ){    std::string str( press );    std::transform( str.begin(), str.end(), str.begin(), toupper );        return str;} 
If you just want to speed that up you should calculate "strlen(press)" once, rather than a times. Or, even better, just loop till you get to the null.

This topic is closed to new replies.

Advertisement