we can't use the special characters in c while declaring the variable.but we use the special character underscore for declaring the variable.
why underscore is exception while declaring the variable in c
Collapse
X
-
Tags: None
-
The underscore was to be used only by programmers developing the C system functions. Regular developers were not to use it at all.
This way if your variable name matched a system variable all would be well because the system variable had a leading underscore while yours did not.
Of course, this doesn't work too well because it relies on humans to follow rules. The problem is resolved in C++ by using namespaces. -
There are a number of reserved identifier patterns. The following list comes from the C99 Standard. By now there may be more reserved patterns. The compiler does not typically warn if you are using a reserved identifier.
Always reserved._[_A-Z][any]
Allowed only for automatic variables._[0-9a-z][any]
Allowed only for static or automatic variables.is[a-z][any]
mem[a-z][any]
str[a-z][any]
to[a-z][any]
wcs[a-z][any]
Allowed only if you don't include the specified header file.E[0-9A-Z][any] (errno.h)
LC_[A-Z][any] (locale.h)
SIG_[A-Z][any] (signal.h)
SIG[A-Z][any] (signal.h)
wcs[a-z][any] (wchar.h)Comment
Comment