Where are strupr and strlwr?

Mar 20, 2010 at 7:51pm
In what library are the strupr() and strlwr() prototyped?
Mar 20, 2010 at 8:58pm
string.h
Mar 21, 2010 at 12:44am
closed account (1yR4jE8b)
I don't think either of those functions are part of the ANSI standard, so you might not have them depending on which compiler you are using.
Mar 21, 2010 at 12:59am
You can do your own easily enough:

C
1
2
3
4
5
6
7
8
#include <ctype.h>

char* stoupper( char* s )
  {
  char* p = s;
  while (*p = toupper( *p )) p++;
  return s;
  }


C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <algorithm>
#include <cctype>
#include <functional>

std::string& stoupper( const std::string& s )
  {
  std::string result( s );
  std::transform(
    s.begin(),
    s.end(),
    result.begin(),
    std::ptr_fun <int, int> ( std::toupper )
    );
  return result;
  }

Etc. Hope this helps.
Topic archived. No new replies allowed.