473,770 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MACRO to capitalize first letter of a word in header.

66 New Member
I know about toupper() and tolower() but I need to capitalize (or de-capitalize)the first letter of a word in a header file. I know there are no preprocessor functions that do that but is there another way?
Jan 7 '09
12 12421
donbock
2,426 Recognized Expert Top Contributor
@dissectcode
Wait a minute ... why do you need the cast? The cast suggests that either the "name" argument to the macro or the "anum" field of the structure is not intrinsically the proper pointer type. Is it a void*?

In general, if you want run-time resolution of pointer types you have a table where each entry contains a void* pointer and an enumeration for all of the possible types that might be pointed to. You then have a big switch on the enumeration value with a case for each possible type. Within each case you explicitly cast the pointer to right kind of pointer type. However, realize that you have no safety net. You have almost no hope of getting a compiler warning/error if you mess up one of those cases by casting to the wrong type.
Jan 8 '09 #11
Tassos Souris
152 New Member
donbock is right..
can you give us please exactly how you need this to work?
I am very curious... what must the name and Name be?
It seems to be that you must follow A LOT OF naming conventions... which of course is only a burden for your mind... things that the compiler cannot check can be tricky..
Jan 10 '09 #12
dissectcode
66 New Member
@Tassos Souris

I think what I am trying to do can only be done using actual C code in functions since the name will depend on run-time inputs. I am using to it access HW registers. Please look at how the word "name" has certain letters in CAPS, or not.

Expand|Select|Wrap|Line Numbers
  1. #define REG_ADDR            ((void *) (0x00054000))
  2.  
  3. #define REG_CASTADDR   ((Name *)(REG_ADDR))
  4.  
  5. #define RD_REG(name, reg)    NAME##_CASTADDR->name##reg.myUint)
  6. #define WR_REG(name, reg, val)  /
  7. ((NAME_REG_BASE->name##reg.myUint) = val)
  8.  
and then from a C program I call the macros:

Expand|Select|Wrap|Line Numbers
  1. int registerState = RD_REG(Regtest, Interrupt_stat);
  2.  
So I need it to turn into :

Expand|Select|Wrap|Line Numbers
  1. REGTEST_CASTADDR->regtestInterrupt_stat.myUint;
  2.  
It looks messy but I made is as general as possible
Jan 12 '09 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1383
by: Colin Steadman | last post by:
Apoligies if this post appears twice, but my first attempt at posting it was hours ago and there is still no sign of it in the forum (says five minutes in the confirmation message). ============================================================================= I have some sample code from Microsoft that allows me to start a specific Word template at the click of a button from within an ASP page. I would like to modify this in such a...
3
23201
by: news.individual.net | last post by:
Hi! Can I capitalize the first letter of the first paragraph without using a special class for that <p> ? I tried it with this: body > p:first-child:first-letter { font-size: 270%;
3
5986
by: gil | last post by:
I have a script that will capitalize the first letter of every word in my descriptions. But some of my descriptions contain ( ) and /. For example bezel (black). I need the script to capitalize Bezel and (Black), but it is only finding the bezel and leaving the (black) in lower case. Here is the script below. Any help would be greatly appreciated. <SCRIPT LANGUAGE="JAVASCRIPT"> <!--
1
4121
by: Dwight Shubert | last post by:
Hi all, This is my first try using Access. I understand how to format a text field for uppercase and lowercase, but how do you capitalize only the first letter of each word? tia Dwight
5
8629
by: DDK | last post by:
What is the best way to capitalize the first letter of a string? Thanks for any help, d.
1
6281
blyxx86
by: blyxx86 | last post by:
I have the code to capitalize an entire string when it is input, but would like to capitalize just the first letter of a box, or match the case of a drop down list.. My current code is thus: Private Sub Serial_AfterUpdate() 'Makes serial field input all caps into database no matter what. Me.Serial = StrConv(Me.Serial, vbUpperCase) End Sub
8
4025
by: romo14 | last post by:
I'm working on a program that will take an address in on all one line separated by pounds (eg karen smith # p.o. box 123 # new york, new york #) and outputs it in user-friendly format. So far my program outputs: karen smith p.o. box 123 new york, new york The only thing I can't figure out how to do is to capitalize the words that need capitalization. I know I need to use the toupper function and I think a for loop, but I don't know how to...
7
16131
by: dizzylizzyd514 | last post by:
I need to make this: introductoRy speEch ==> Introductory Speech pRecalCulus 1 and 2 ==> Precalculus 1 And 2 I know how to capitalize the first letter of a word, but not multiple words in a string like the examples shown. Any ideas????
12
4002
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.