Function to convert null terminated string to uppercase?

I'm new to C++ so the q might seem easy.
With which function I convert null terminated string to uppercase?
char *s="adac";
somefunc(s);
now *s is "ADAC"
LVL 1
mdannyAsked:
Who is Participating?
 
nietodConnect With a Mentor Commented:
_strupt is fine.  But it is not a standard function.  It is one that Microsoft provides with their compiler, but it might not be found on onther compilers.  The fucntion I wrote is portable, so it can be used on ANY compiler.

>> Get unhandled exception error
There is no problem with the function I provided.  The problem must be elsewhere in the program or in the way you are using the function.

It is not necessary to reject an answer if you simply want clarificationor additional help.  You ca simply post a comment askign for more help.
0
 
nietodCommented:
You can use toupper() to convert a single character to uppercase.  

You can write code to convert an entire string like

void UprStr(char *str)
{
   while (*str)
   {
        *str = toupper(*str);
        ++str;
    }
}
0
 
mdannyAuthor Commented:
Tried it.Get unhandled exception error...Also tried the function    _strupr from <string.h>
I'm using vc6,win32 console.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
mdannyAuthor Commented:
Sorry I found my mistake...
Thanks nietod
0
 
KangaRooCommented:
nietod's function looks correct. Try with

char* src = "adac";
char* dup = strdup(src);
UprStr(dup);
cout << dup << endl;
0
 
nietodCommented:
>> nietod's function looks correct.
But its always hard to be sure with a function of that sort of complexity.  There may be a bug lurking somewhere.  :-)
0
 
WynCommented:
Great humour...
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.