Basic Note :
- Global predefined macro starts with underscore. (_) .
- We cannot use Global predefined macro as our function name.
Example : Some of the predefined macros in C
- __TIME__
- __DATE__
- __FILE__
- __LINE__
Learn by Program : Valid Example
#include<stdio.h>
void __FILE__();
int main()
{
__FILE__();
}
void __FILE__(){
printf("Hello World");
}
Output :
Compile error
We can have valid function names starting with underscore -
- _add()
- _getTime()
- _calsum()
Note :
Try to avoid using underscore as first character .
Why we should avoid to use underscore as first character ?
- Using underscore as first character is perfectly legal in C.
- But in C we have many more different predefined constants and macros starting with underscore.
- It will create confusion between user defined and predefined identifier.
- so prefer not to use underscore as first character in writing function.
You may like these articles :
- Learn C Function by Example 2 : Name of Function Cannot be Keyword of C
- Learn C Function by Example 1 : Underscore and Alphanumerics are allowed
- C Programming Quiz Answer : Variable Name Validity
- Pointers in C Programming : Learn Pointer Tutorials
- Advantages of File scope / Global Variable in C Programming
- What is Global Variable and Scope in C Programming ?
- Disadvantages of File scope / Global Variable in C Programming
- Advantages of Block scope / Local Variable in C Programming
- Read Character from Stream using getc Macro (stdio.h)
- Disadvantages of Block scope / Local Variable in C Programming
About the author: Pritesh View all posts by Pritesh
My name is Pritesh Taral. I am working in well known MNC. as Java Developer. I am part time blogger loves writing articles on C/C++.
I am active on facebook using community fan page .One can Visit me @ Facebook
Facebook Fan Page