473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Convert char* to upper case

Hi,

For some reason I am blanking this Friday morning. I have a class
constructor call Point as shown below. Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.

Thanks for the insight.

RishiD

Point(const char* name,
const char* description,
const char* iomid,
const char* address,
const char* type,
Event* event)
{
m_strName = name;
m_strDesc = description;
m_strAddress = address;
m_strType = type;
m_strParentName = iomid;
m_Event = event;
}

Feb 16 '07 #1
13 23742
RishiD <ri****@gmail.comwrote:
For some reason I am blanking this Friday morning.
Starting with posting code that seems a little like C++ to
comp.lang.c? (It has indeed been a lengthy week.)
I have a class
constructor call Point as shown below. Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.
There's no builtin C function to do this, but you could write one
using the builtin toupper() for characters. Alternatively, there
might be a C++ way to do this, if you are indeed writing C++ as it
seems.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Feb 16 '07 #2
RishiD said:
Hi,

For some reason I am blanking this Friday morning. I have a class
constructor call Point as shown below.
....which makes me think you're using C++, so I've cross-posted this
reply to comp.lang.c++, and set followups to that group.
Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.
In C, you'd probably write a function that calls toupper() in a loop -
but in C++ there may be a more C++y way to do it.

[Remainder of your article retained, for clc++'s convenience. Hi guys,
long time no see.]
>
Thanks for the insight.

RishiD

Point(const char* name,
const char* description,
const char* iomid,
const char* address,
const char* type,
Event* event)
{
m_strName = name;
m_strDesc = description;
m_strAddress = address;
m_strType = type;
m_strParentName = iomid;
m_Event = event;
}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 16 '07 #3
Christopher Benson-Manica wrote:
>RishiD <ri****@gmail.comwrote:
>>... Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.

There's no builtin C function to do this, but you could write one
using the builtin toupper() for characters. Alternatively, there
might be a C++ way to do this, if you are indeed writing C++ as it
seems.
[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
services provided in <ctype>

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Feb 16 '07 #4
RishiD wrote:
Hi,

For some reason I am blanking this Friday morning. I have a class
constructor call Point as shown below. Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.

Point(const char* name,
const char* description,
const char* iomid,
const char* address,
const char* type,
Event* event)
{
m_strName = name;
m_strDesc = description;
m_strAddress = address;
m_strType = type;
m_strParentName = iomid;
m_Event = event;
}
#include <ctype.h>

void up(char *q)
{
unsigned char c;

while (*q) { c = *q; *q = toupper(c); q++; }

return;
}

Also your function specifies "const char *". You might want to adhere to that.
Feb 16 '07 #5
Roberto Waltman wrote:
[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^

???
Feb 16 '07 #6
Christopher Layne wrote On 02/16/07 11:07,:
Roberto Waltman wrote:

>>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

^^^^^^^^^^^^^^^^^^

???
Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.

--
Er*********@sun.com
Feb 16 '07 #7
Christopher Layne wrote:
>Roberto Waltman wrote:
>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^
Off-topic, wearing a C++ hat:
From Josuttis "The C++ Standard Library", 1st ed, 10th printing, page
716.

The facet ctype is a template class parameterized with a character
type...
....
Table 14.16. Services defined by the ctype<charTFacet
....
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Feb 16 '07 #8
Eric Sosman wrote:
Christopher Layne wrote On 02/16/07 11:07,:
Roberto Waltman wrote:

>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^

???

Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.
The C++ part? toupper(begin,end) is new to me if it's valid at all,
regardless of which language is used.

Feb 16 '07 #9
Eric Sosman wrote:
Christopher Layne wrote On 02/16/07 11:07,:
Roberto Waltman wrote:

>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^

???

Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.
The C++ part? toupper(begin,end) is new to me if it's valid at all,
regardless of which language is used.

Feb 16 '07 #10
Roberto Waltman wrote:
Christopher Layne wrote:
Roberto Waltman wrote:
[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^
[un-snip]
services provided in <ctype>

Off-topic, wearing a C++ hat:
From Josuttis "The C++ Standard Library", 1st ed, 10th printing, page
716.

The facet ctype is a template class parameterized with a character
type...
...
Table 14.16. Services defined by the ctype<charTFacet
...
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()
Oh, provided by a ctype class, not provided by any <ctypeheader...?

Feb 16 '07 #11
Eric Sosman wrote:
Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.
You are correct. I thought he was responding in general, not specifically to
the C++ part. Part of that may be due to the fact that I don't generally
think in any C++ mode while i'm in this NG.
Feb 16 '07 #12
"Harald van D?k" wrote:
>Roberto Waltman wrote:
>... C++ stuff ...
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()

Oh, provided by a ctype class, not provided by any <ctypeheader...?
[Still-off-topic] Beginning to get beyond my depth, (no books at hand
now.) I believe it is provided by the standard headers, but somehow
linked to (buried under?) the locale selection mechanisms.

There is also a toupper(c, loc) that will convert c to upper case IFF
it is a lower case character in locale loc.

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Feb 16 '07 #13

"Christopher Layne" <cl****@com.anodizedwrote in message
news:11************@news-west.n...
RishiD wrote:
>Hi,

For some reason I am blanking this Friday morning. I have a class
constructor call Point as shown below. Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.

Point(const char* name,
const char* description,
const char* iomid,
const char* address,
const char* type,
Event* event)
{
m_strName = name;
m_strDesc = description;
m_strAddress = address;
m_strType = type;
m_strParentName = iomid;
m_Event = event;
}

#include <ctype.h>

void up(char *q)
{
unsigned char c;

while (*q) { c = *q; *q = toupper(c); q++; }

return;
}

Also your function specifies "const char *". You might want to adhere to
that.
Especially since this can cause bad things to happen using the above code:
char *ptr = "test";
up(ptr);
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
Feb 16 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: programmerforhire | last post by:
Hello all, Is there a way to setup an ms-access table so that when I enter text in the 'datasheet' mode, it will automatically be converted tp upper case. Or must I use a Form for this? rex
3
by: Addio | last post by:
Hello, MSA Group, Does anyone know how to convert all UPPER CASE text to Initial Caps? I'm familiar with ucase and lcase, but don't know of any function to handle Initial Caps, i.e. every word...
17
by: Janice | last post by:
char* line = "abcd"; How to convert the line to upper case and print? Any option for printf to do this? Thanx
6
by: Manish | last post by:
In my application there is need for only upper case chars.. Currently I am making entry to upper case when user leaves focus of the text control. I want to do some modification here...When user...
5
by: Mariame | last post by:
Hi Everyone, Is There a way to eliminate upper case, so the user could only write Lower Case or to transfer the Upper Case String to lower case in Visual Basic ???? Thx in Adv.
19
by: Eric Lindsay | last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case? I understand that HTML allows either upper or lower case. I also notice that XHTML apparently requires lower case. However I...
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
5
by: conan9 | last post by:
Hi folks,, I'm new here and having trouble to compile uppercase .... and here is my code: #include <iostream> #include <string> #include <iomanip> #include <algorithm>
6
by: lenniekuah | last post by:
Hullo Awesome Helpers, Thank you for helping me earlier. I am back with new problem. I am trying to covert a TEXT String into either Lower and Upper case characterS. (Upper case Eg. ALFRED instead...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.