Where are strupr and strlwr?

In what library are the strupr() and strlwr() prototyped?
string.h
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.
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.