![]() |
|
#1
|
||||
|
||||
C++ Syntax Highlighter related questionWhen you name a variable in C or C++ what are the valid "characters" one can use?
Obviously alphabets are okay, I assume the underscore is also okay... what else? So, the following is valid variable names? Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
||||
|
#2
|
|||
|
|||
|
Quote:
Legal characters in variable names are: Letters, digits. The first character must be a letter. And, of course names are case-sensitive. Key words (if, else, for, float, etc.) are reserved. Now, the underscore counts as a letter, but note that the C standard says that names with two underscores in a row and names that start with an underscore are reserved for use by the implementation (compiler, linker). I have never seen a compiler that doesn't allow user names that begin with an underscore. I don't see how they could enforce this since standard library headers have something like the following: CPP / C++ / C Code:
I don't want to seem too pedantic, but I would avoid having any user named item begin with an underscore. Regards, Dave |
|
#3
|
||||
|
||||
|
Thank you Dave.
What about the dollar sign? Maybe a variable named $myvar? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#4
|
|||
|
|||
|
Quote:
Nope. Not in C or C++ Regards, Dave |
|
#5
|
||||
|
||||
|
Thank you again and I am moving this to the GIDForums™ Feedback forum where it really belongs.
![]() __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Repetition structure problem and question | brookeville | C++ Forum | 17 | 29-Oct-2004 17:48 |
| Hmm what seems to be the problem here? error C2061: syntax error | pablowablo | C++ Forum | 5 | 12-Jun-2004 22:11 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 07:17 |
| a C input question | tmike | C Programming Language | 1 | 16-Sep-2003 02:31 |
| 'Related articles' php /mysql question | JdS | MySQL / PHP Forum | 4 | 06-Sep-2002 10:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The