• C

Easy, just can't find info (type def)

Hi,

1) The line:
#define BLAH `g' means that BLAH is defined as a character right??

2) What is f, and h? (f=float?) Can you give me a list of some others please?

3) I am reading some document, maybe you can help me clarify.

"Adding debugging info: an alias needs to be added to the BLAH array, which is exactly 4 char long. The debugging task alias should be added in ascending order of task name so that the tools function proprly. task names are case sensitive. In running example, BLAH evaluates to 'g', and should therefore fi below 'f' and above 'h'."

so, what am I asking? is this saying that you are supposed to alphabetise the definition types? what if both BLAH1 and BLAH2 evaluate to 'g'? Is this possible?

all help would be appreciated, but big points, so please do a good job. Thanks!
ibarrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ibarrAuthor Commented:
Adjusted points to 150
0
ozoCommented:
1) Actually, it looks more like BLAH would be a syntax error.
2) In what context?
3) Perhaps.  What are the tools to which the document refers?
0
ibarrAuthor Commented:
ok, thanks for the comment.

1)ok, but you know what I mean. Is 'g' another way to say char??

2) in the same context as above, only f and h, instead of g.

3) I don't know how to tell you what tools are relevant. Based on what is written, can you interpret please?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ozoCommented:
1) In C, 'g' is another way to say 103 (assuming your character set is ASCII)
`g' would be meaningless
2) 'f' is another way to say 102, and 'h' is another way to say 104
3) Based on what is written, it seems to be talking about adding debugging info.  Not being familiar with the example it is talking about, it is difficult for me to interpret furthur.
0
obgCommented:
Are you by any chance referring to the printf format speciiyers (where %g means float or double, %f means the same in standard form - no exponent stuff, and %h means absolutely nothing)?

In that case, here's a list from Borland:
 Type |                |
 Char | Expected Input | Format of output
------+----------------+---------------------------------------------------
 Numerics
------+----------------+---------------------------------------------------
   d  | Integer        | Signed decimal integer
   i  | Integer        | Signed decimal integer
   o  | Integer        | Unsigned octal integer
   u  | Integer        | Unsigned decimal integer
   x  | Integer        | Unsigned hexadecimal int (with a, b, c, d, e, f)
   X  | Integer        | Unsigned hexadecimal int (with A, B, C, D, E, F)
   f  | Floating point | Signed value of the form [-]dddd.dddd.
   e  | Floating point | Signed value of the form [-]d.dddd or e[+/-]ddd
   g  | Floating point | Signed value in either e or f form, based on
      |                | given value and precision. Trailing zeros and
      |                | the decimal point are printed if necessary.
   E  | Floating point | Same as e; with E for exponent.
   G  | Floating point | Same as g; with E for exponent if e format used
------+----------------+---------------------------------------------------
 Characters
------+----------------+---------------------------------------------------
   c  | Character      | Single character
   s  | String pointer | Prints characters until a null-terminator is
      |                | pressed or precision is reached
   %  | None           | Prints the % character
------+----------------+---------------------------------------------------
 Pointers
------+----------------+---------------------------------------------------
   n  | Pointer to int | Stores (in the location pointed to by the input
      |                | argument) a count of the chars written so far.
   p  | Pointer        | Prints the input argument as a pointer; format
      |                | depends on which memory model was used. It will
      |                | be either XXXX:YYYY or YYYY (offset only).

Hope it helps!
0
3rsrichardCommented:
I think he may mean the type identifiers, and I can't find a list.
The ones I recall are
'  character code
h  hex
l  long
f,g float or double
o  octal
b  bit string ( as in 01011B)
x hex
0
bluezenCommented:
I think a relevant point is that if you #define item1 item2
then wherever in the code item1 exists, it is converted to item2 while compiling
for example

#define ck printf
main()
{
ck("hello world");
}

means that ck is recognized and converted to printf when compiling

I think ibarr perhaps you are confusing a couple of concepts...print specifiers [which tell the printf routine in which format you want the output]
and #define which is a preprocessor directive which basically is used to convert all references to a particular bit of text (could even be 'a'!) to another bit of text
Please let me know if any further clarification is  required or you could tell us something that would make it easier for us to help you
0
bluezenCommented:
BTW ... reading your question again it struck me
If you said #define BLAH g and
then used BLAH1 and BLAH2 they would be converted to g1 and g2 when compiling
Hope that helps
0
obgCommented:
I am not absolutely sure, but very close to it. If BLAH is defined as g then BLAH1 is something completely different, and not at all necessarily g1.

I do not really understand the question... Of course you can define both BLAH1 and BLAH2 as 'g'. These defines are evaluated by the precompiler (before compilation). It's kind of a search-replace thing...
0
abdijCommented:
HI,
bluezen:
>> #define ck printf
means that ck is recognized and converted to printf when compiling

#define is a Precompiler option. The precompiler replaces the ck with printf for the compiler.

same goes with #include. The precompiler replaces the code for the included functions before the compiler compiles. There is a difference. But ofcourse all compilers preprocess before compilation.

#define VAL VALUE is just text replacement of VAL with VALUE.

It is generally used in case when there is a particular need for the Macro.
For example let us say the Program to find Simple interest.
Tou can use a statement like:
 dSi = fPrinci * 14.5 * nDuration /100;
where 14.5 is the Rate of interest which is currently constant.
This calculation or (14.5) rate of interestr value may be used a lot of time in your program.
But tomorrow the the Rate of Interest changes then you have to search through the program and find where all you have 14.5 (sometimes it might stand for something else altogether different!!!) and change them

Instead define
#define RATE_OF_INTEREST 14.5

dSi = nPrinci * RATE_OF_INTEREST * nDuration /100;

now you only need to change 14.5 to 15 in only one playe
#define RATE_OF_INTEREST 15

The precomiler will do the rest.

Other frequently applied use are:
Array MAX bounds
int array[MAX_SIXE];
char szName[MAX_NAME_LEN];

Loop conditions:

for(i = 0; i < strlen(szName) || i < MAX_NAME_LEN; i++)

And NO,
if BLAH is g
BLAH1 is not g1

it is plain text replacement.


Hope this helps
Bye
Abdij
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abdijCommented:
Hi,
 Sorry i did not go through the point 3. I was so carried by the #define!!!!!

Ok here is what you asked:
>>
"Adding debugging info: an alias needs to be added to the BLAH array, which is exactly 4 char long. The debugging task alias should be added in ascending order of task name so that the tools function proprly. task names are case sensitive. In running example, BLAH evaluates to 'g', and should therefore fi below 'f' and above 'h'."
>>

In this explanation it says the BLAH is a char[4] type.
I guess it is some sort of menu or what???
And what ge means is that the current example during the run time BLAH equates to 'g' actually "g\0". and therefore is below "f\0" and above "h\0".

Please explain what you are doing and where this explanation was provided. Its quite vague.

What he says is in order that the tool works correcttly the BLAH array should be in ascending order of the tasks. Now what are these task names??????

Explain.

Sorry for the overlook.
Bye
Abdij
0
ibarrAuthor Commented:
hi, thank you for all you help,
.... everyone.

I am working on something else, but will need to return to this document shortly. I understand that my question was quite vague. Although your answers have shed some light. I will get back with more details.  Thanks again.

(is there anyway to split points between people?)

you will hear from me soon
0
abdijCommented:
Yes,
 You can post the question in the Expert Exchange
http://www.experts-exchange.com/Customer_Service/Experts_Exchange

Section.

Bye
All the Best
Abdij
0
ibarrAuthor Commented:
hi, thank you for all you help,
.... everyone.

I am working on something else, but will need to return to this document shortly. I understand that my question was quite vague. Although your answers have shed some light. I will get back with more details.  Thanks again.

(is there anyway to split points between people?)

you will hear from me soon
0
abdijCommented:
Yes,
 You can post the question in the Expert Exchange
http://www.experts-exchange.com/Customer_Service/Experts_Exchange 

Section.

Bye
All the Best
Abdij
0
ibarrAuthor Commented:
hi, thank you for all you help,
.... everyone.

I am working on something else, but will need to return to this document shortly. I understand that my question was quite vague. Although your answers have shed some light. I will get back with more details.  Thanks again.

(is there anyway to split points between people?)

you will hear from me soon
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.