473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

why underscore is exception while declaring the variable in c

we can't use the special characters in c while declaring the variable.but we use the special character underscore for declaring the variable.
Mar 22 '17 #1
2 987
weaknessforcats
9,208 Expert Mod 8TB
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.
Mar 22 '17 #2
donbock
2,426 Expert 2GB
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)
Mar 23 '17 #3

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

Similar topics

4
by: Mikael Petterson | last post by:
Hi, I got some help to go from: bbBusState to BB_BUS_STATE. However I found out :-( that the xml contained attributes like: TxDeviceGroup and that becomes:
2
by: R.G. Vervoort | last post by:
is it possible to declare a variable in the onchange event of a <select> and use it later in php I would like to put the value of the selected option (in <select>) in a variable and later when i...
5
by: fred | last post by:
I don't know if I'm doing this correctly. I have a little programming experience in python, c++ and some others but this is my first time with javascript. I'm trying have my website detect the...
6
by: Steve Jorgensen | last post by:
Many of the regulars here have explained that declaring variables using As New .... is a bad idea, and some have given some good explanations, but I wanted add one more demonstration to the mix. ...
14
by: Bit Byte | last post by:
I have the following struct: typedef struct { string symbol; string synonym; Synonym(string _synonym, string _symbol) { synonym = _synonym; symbol = _symbol; }
9
jacoder
by: jacoder | last post by:
i amm on my 4th C class ever;) i have taken to the language ok but im stuck trying to declare the values of my 3 variables hers my effort HOPE SUMONE CAN CORRECT THIS MESSY CODE & LEND A HELPING...
2
by: vlsidesign | last post by:
Here is my a portion of my program: #include <stdio.h> main() { int fahr, celsius; int lower, upper, step; int fc_conv(int fahr); ... snip ... }
7
by: billq | last post by:
Hello, I ran across a code snippet with declared a variable like private Viewport? viewport I do not understand the use of the ? in the code. Thanks Bill
2
by: cbrrr | last post by:
I have the variables declared twice where i think they should be. If I declare them global I get an uninitialized error, the other position gives me a declaration error. Im using visual C++ express...
4
by: Busbait | last post by:
Hi I am trying to declare a variable as a FileDialog object in VB for MS Access 2007 Dim fd As FileDialog But, I am receiving an error message “ Compiler error : User-Defined type not...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.