Macro gets to see the Compilation environment.
It is expanded by the preprocessor.
For example, you can't do this without macros:
#define PRINT(EXPR) printf( #EXPR "=%d\n", EXPR)
PRINT( 5+6*7 ) // expands into printf("5+6*7=%d", 5+6*7 );
You can define your mini language with macros:
#define strequal(A,B) (!strcmp(A,B))
Macros are a necessary evils of life. The purists don't like them, but without it no real work gets done.
2. Difference between const char* p and char const* p
In const char* p, the character pointed by 'p' is constant, so you cant change the value of character pointed by p but you can make 'p' refer to some other location.
in char const* p, the ptr 'p' is constant not the character referenced by it, so you cant make 'p' to reference to any other location but you can change the value of the char pointed by 'p'.
3. Can a variable be both const and volatile?
Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. If a variable is both const and
volatile, the two modifiers can appear in either order.
4. How are pointer variables initialized?
Pointer variable are initialized by one of the following two ways
- Static memory allocation
- Dynamic memory allocation
5. When should a type cast not be used?
A type cast should not be used to override a const or volatile declaration. Overriding these type modifiers can cause the program to fail to run correctly.
A type cast should not be used to turn a pointer to one type of structure or data type into another. In the rare events in which this action is beneficial, using a union to hold the values makes the programmer's intentions clearer.
Published by BitMan
- Jessica Simpson: The Interview You've Been Waiting forWe all know Jessica Simpson is one of the most well-known pop singers of today. What you might not know, however, is what she's like during an interview at her home where she is free to be herself.
- Are You a Victim of Social Engineering?Social Engineering is an art that is practiced by someone who will try to gain your trust through dishonest means. They will try to "help" you or ask you for help and to become your new "friend".
- Argument in Favor of Genetic Engineering of Human BeingsA college philosophy paper in support of genetic engineering of human beings.
- How to Prepare for a Job InterviewAre you looking for a job? Would you like to know how to have a successful job interview? Employers are looking for the best qualified people for the positions that are open.
- On the Job Hunt? Make Your Interview a Success!Ten key tips and techniques to make the interview portion of the hiring process a success.
- C Programming HOW-TO
- The Fundamentals of C++
- Top 20 C & C++ Interview Questions
- Top 10 Interview Questions for Embedded Hardware Engineers - Memory Systems
- Media Relations 101: How to Conduct a Successful Interview with the Press
- Tips for Having a Successful First Job Interview
- Variable Compression, Artificial Fuels and the Car of the Future




2 Comments
Post a CommentMarcin Olak is right
"const char* p" and "char const* p" mean precisely the same. In the second case you obviously meant "char* const p" which would be "p which is constant pointer to char".