C/C++ :: Use Of Underscore In Front Of Brackets?
Apr 10, 2014
I am currently reading the source code of Nitrogen [URL] ..... and I stumbled upon the following line of code in ArgParser.cc:
error_str += _("Unexpected argument ") + key + "
";
(error_str and key are std::string)
why there is an underscore in front of the brackets ?
By this I mean what does it do/achieve ?
View 4 Replies
Feb 6, 2012
I've always been bothered when people say "don't name your variables with a leading underscore, it is reserved by the implementation", so I decided to ask this once and for all.
The actual standard says:
17.6.4.3.2 Global names [global.names]
1 Certain sets of names and function signatures are always reserved to the implementation:
- Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.12) is reserved to the implementation for any use.
- Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
Unless I'm mistaken I read this as:
Words like "__foo" or "_BAR" are strictly off limits, as the implementation may have used it as a macro.Words like "_foo", when used for things such a member variables, or scoped variables on the stack are fine. The implementation only gets to use those as global functions inside mainspace.
So my question is this: While using leading underscores is generally frowned upon, is it, strictly according to the standard, wrong?
View 5 Replies
View Related
Sep 3, 2013
I have a character array that will have a prefix and then a filename that will be between two square brackets. Something like this;
get[filename]
I need to isolate the characters between the brackets. Here is my attempt:
Code:
char* get_filename(char selection[]) {
char* ptr;
char* rv;
char* temp;
ptr = strtok(selection, "[");
ptr = strtok(NULL, "[");
[Code] ....
But of course, this isn't working.
View 4 Replies
View Related
Mar 14, 2013
How would I make the program still display zeros in front of a number?
Like say for example:
cout << "Enter any number";
cin >> number;
cout << number;
Let's say I entered 0003 as my input. How would I make it to where it will display the three zeros in front of the 3 instead of just displaying 3?
View 1 Replies
View Related
Mar 24, 2014
I had a quick question about how to check the balance of brackets in an HTML file using a stack (pushing and popping). I understand pushing and popping. I get lost when it comes to the logic of having to actually check what is in the brackets, and making sure those are nested correctly.
So while
<title><b> THIS FILE </b> USES CORRECTLY NESTED TAGS </title>
is correct and
<title> <b> THIS FILE </title> IS </b> NOT NESTED CORRECTLY.
is incorrect;
How do I check for the actual tags inside the brackets, keeping in mind that there are single sided tags as well.
(ex. <img src="a.jpg"/>)
View 8 Replies
View Related
Oct 10, 2013
I have to write a method that moves a node to the front of one. Here is what I have:
template<typename T>
void DoublyLinkedList<T>::moveToFront(ListNode<T>* n)
{
[Code].....
I've walked through it a few times, and I feel like this correct. However, my program's output is off and I'm guessing this function is the culprit. I think I just need a different pair of eyes to take a look at it.
View 2 Replies
View Related
Apr 25, 2014
I am reading a file whick looks like following:
Code:
10 = NAND(1, 3)
11 = NAND(3, 6, 5)
15 = NAND(9, 6, 2, 8)
Problem: I have to find the word "NAND" and then find the numbers inside the brackets because they are the inputs to that NAND gate. I have written a code below but that code can detect the fixed number of inputs. I need a code which can detect any number of inputs (whether 2 inputs or more than two). But i don't understand how do i do that?
My code:
Code:
string input_str ("INPUT"), output_str ("OUTPUT"), nand_str("NAND");
while (getline( input_file, line ))
{
std::size_t guard_found = line.find(guard_str);
[Code].....
View 8 Replies
View Related
Apr 7, 2013
I am programming a translator, and I have it so that it detects words with spaces both in front of and behind them, so I did "string.append(space);" where space equals " ". That added a space to the end, but I still need a space added to the front.
View 1 Replies
View Related