This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I've seen a pretty strange (for me) usage of this method:
strncpy(somePointer,"%d",someInt);
What does this actually do? The integer specifier "%d" as the source is troublesome for me to understand.
It does what it says on the tin: It copies the literal string "%d" into a char buffer pointed to by somePointer, or at least the first someInt bytes of it (up to three).
Don't be upset by a percentage sign, it's just another character...
Related
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I found a C++ file in PARSEC benchmark suite and saw some functions like this:
long Rng::rand()
{
return _rng->randInt();
}
what does the :: in the name of the function do here?
In C, :: is a syntax error unless it occurs inside a comment, a character literal or a string literal.
The :: can only appear in C++ code.
In C++ :: is the Scope resolution operator.
In this case it tells the compiler that it is a defintiion for rand() method which is a member function for Rng class/structure/union/namespace.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I am modifying some C++ code that has a wchar_t myArray[MAX_PATH] in the header file.
My modifications mean that I cannot know the length of this array until runtime. How can I store an array of dynamic length instead? Maybe I just keep a wchar_t* in the header file and another int to hold its length?
Use std::wstring instead. It's a dynamic string containing wchar_t.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Ogre::any_cast<std::map<Rail>::iterator>
It takes Ogre::any_cast<std::map<Rail> and says too few arguments etc. How can I fix it (other than obvious typedef aliasing)?
The problem is that std::map takes at least two template arguments - the key type and the value type. Currently you have std::map<Rail>. What are you mapping from Rail to? For example, this would be okay if your iterators are for a std::map that maps from Rail to int (assuming Rail is not a deduced type):
Ogre::any_cast<std::map<Rail,int>::iterator>(some_any_object)
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Can anyone tell me meaning or possible values of below regular expression?
/(\+\d{2})/
Plus followed by a number on 2 digits.
This matches for instance: +23
A + followed by 2 digits: +23 +01 etc.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
if((kulax>=schodki[i][0][0] && kulax<=schodki[i][1]][0]) && (kulay==schodki[i][2][0]+10))
spoczywa=true;
Hi guys, I have an array of integers which name is schodki and it is declared as int schodki[5][3][1] and the global variables : int kulax and int kulay.
What's wrong in the line of code which is above ?
EDIT : Of course. "i" is the value from current state of loop.
You have an extra ] in
kulax<=schodki[i][1]][0]
which probably screws up parsing and results in a confusing error message. The compiler probably sees it as
kulax<=schodki[i][1]
which is indeed an attempt to compare an integer to a pointer. Try to pay attention to your own code and make sure it is free from primitive syntax errors before asking questions here.
Other than that, there's nothing wrong with your code (assuming that the variables are really declared the way you say they are)].