To Uppercase

Hi there
I'm in a sticky situation and dunno my way out. My app required a logfile during runtime. While writing into the logfile certain int data were to be represented in the their hex format in the file. I used itoa() function. In my resultant char array i got the hex value which was written into the file. But like the no. A-F hex are present in lower case and i want them in upper case. How do I do that?
I've looked up MSDN and found ToUpper and toupper there but they were not useful, in fact gave compilation errors. Is there any specific header to be included for their proper functioning? I've used iostream, fstream and string headers in my cpp file.

sam
[698 byte] By [techsam] at [2007-11-19 6:38:26]
# 1 Re: To Uppercase
hi there
u told that result is stored in char array.
now if this array contains the value like 2323adc

that it will give u compliation error.
firstly try a simple function like toupper("practice");
if this works than i think
that there might be no other function to convert this.

moreover toupper function does not require any other files to be included.
siya_pandya at 2007-11-11 0:30:28 >
# 2 Re: To Uppercase
hi siya
i suppose u didn't get my situation. it's like it seems u r working on the premise that i know the contents of my char array. the truth is no , i don't . there are three such arrays ch1[2] , ch2[4] , ch3[6] . the value in there can only be guessed . while the second has a fixed range which is nearly 200 values ( 80 - 9E , and 9F1F - 9F7F) thats a lot . i really don;t know which one would occur when. what i need is a function to convert them irrespective of thier length in a manner that only the lowercase are converted to uppercase and the rest remain as it is.
i hope get the gist of the situation.
sam
techsam at 2007-11-11 0:31:28 >
# 3 Re: To Uppercase
now if this array contains the value like 2323adc

that it will give u compliation error.Compiler error? :confused: Why should that be?
gstercken at 2007-11-11 0:32:29 >
# 4 Re: To Uppercase
I used itoa() function. In my resultant char array i got the hex value which was written into the file. But like the no. A-F hex are present in lower case and i want them in upper case. How do I do that?You have two at least two ways to solve that: Either convert the resulting string to upper case by using toupper - but note that the C library function (from stdlib.h) converts a single char (not an array). ToUpper() is a member of CString, and requires MFC.
The second (IMO, more straightforward) approach is to drop itoa() and use sprintf() instead, where you can use the "%X" format string to get hex digits in uppercase.
gstercken at 2007-11-11 0:33:34 >
# 5 Re: To Uppercase
So like wot u r saying is i convert one char from array at a time to uppercase.
i believe the format should be : toupper(ch1[0]) ; -- for the first char in array.
sam
techsam at 2007-11-11 0:34:37 >
# 6 Re: To Uppercase
So like wot u r saying is i convert one char from array at a time to uppercase.No, what I'm rather saying is to use sprintf(). Of course, you can also go through yur arrays in a loop and convert every single character if you like...
gstercken at 2007-11-11 0:35:36 >