i was learning about c++ pointers... so the "->" operator seemed strange to me... instead of
ptr->hello();
one could write
(*ptr).hello();
because it also seems to work, so i thought the former is just a more convenient way
is that the case or is there any difference?
...
I'm having a hard time using std::string::iterators in C++. This code compiles fine (still not getting correct output, but that's my fault: TODO, fix algorithm) in Dev-C++, and I don't get runtime errors. The error is with Visual Studio Express 2008 C++, where I'm getting an error pointing to < xstring>: "Expression: string iterator not ...
I'm trying to do some classic C development in Visual C++ 2008 that will modify the characters of a string like so:
void ModifyString(char *input)
{
// Change first character to 'a'
*input = 'a';
}
I'm getting a unhandled exception when I try to change a character. It seems like I could do this in Visual Studio 6 or using gcc, bu...
I have a directory on a Linux system that mostly contains symlinks to files on a different filesystem. I'd like to add the directory to a Subversion repository, dereferencing the symlinks in the process (treating them as the files they point to, rather than links). Generally, I'd like to be able to handle any working-copy operations wi...
I have a function that returns an array of different lengths based on a table lookup. I am malloc'ing required memory for it inside the function but then how can I fill the array from its pointer?
The compiler is throwing same error for both of my tries (commented lines). Please help!
int lookup(const char *name, float *factors) {
i...
I'm doing (something like) this:
void insert(Node*& node, string val, Node* parent)
{
if (node == NULL)
instantiateNode(node, val, parent);
else
insert(node->child, val, node);
}
The thing is, that instantiateNode(..., parent) seems to modify the original *&node passed into the function when setting the *parent. instan...
I have the following defined:
Stack<ASTNode*>* data;
The way the class is defined, if I do data->push() or data->pop(), I directly push onto the stack or pop off the stack. To get the node at the top of the stack I would do data->peek(). For testing purposes, I would like to print out the top node in the stack like this:
cout << "top...
How should I write my code to example a specific array index of an array that happens to be a member of a structure? The following code is giving me problems.
// main.c
void clean_buffers(void); // prototype
struct DEV_STATUS {
unsigned char ADDR;
unsigned char DEV_HAS_DATA;
unsigned char ETH_HAS_DATA;
unsigned char D...
I have noticed that when I was running Windows XP, if my code dereferenced null I would get a crash in debug and I could then easily identify where the bug was coming from. It seems that in Windows 7 (I'm running 64-bit), instead of crashing or creating any sort of notification, the code will simply break its current iteration and start...
How to control LDAP Alias Dereferencing Mode using Java and Spring LDAP API?
Similarly to how it is done using ldapsearch on linux.
Example:
ldapsearch -a never "(&(o=foo)(cn=bar))" cn
ldapsearch -a always "(&(o=foo)(cn=bar))" cn
...
I am compiling this piece of code and I get compliation errors saying " dereferencing pointer to incomplete type" .
I get the errors for the last print statement and before that where I try to point (*temp). num to the address of b
Here's the code snippet:
void main()
{
struct {
int xx;
char *y;
int * nu...
I have a problem with dereferencing a Javascript object and setting it to NULL.
Here, I have a Folder implementation that supports recursive subdirectory removal. Please see my comments to understand my dilemma.
function Folder(name, DOM_rows) {
this.name = name;
this.files = [].concat(DOM_rows);
this.subdirs = [];
}
Fold...
Hi everyone, I've come across a problem related to pointers within arrays in objective-c.
What I'm trying to do is take the pointers within an NSArray, pass them to a method, and then assign the returned value back to the original pointer(the pointer which belongs to the array).
Based on what I know from C and C++, by dereferencing th...
I am new to Perl and am curious whether @{$list_ref} and @$list_ref are perfectly equivalent.
They seem to be interchangeable, but I am nervous that there is something subtle going on that I may be missing.
...
When I try to use a set iterator in debug mode in C++, I get an error that says "map/set iterator not dereferencable". I don't understand because I thought dereferincing was how you are supposed to use an iterator. The code looks like this:
set<int>::iterator myIterator;
for(myIterator = mySet.begin();
myIterator != mySet.end();
...
Hi!
If i have in C++ a pointer to a vector:
vector<int>* vecPtr;
And i'd like to access an element of the vector, then i can do this by dereferncing the vector:
int a = (*vecPtr)[i];
but will this dereferencing actually create a copy of my vector on the stack? let's say the vector stores 10000 ints, will by dereferencing the vecPt...
I just wrote the following line of code:
if (++(data_ptr->count) > threshold) { /*...*/ } // example 1
My intent is to increment the count variable within the data structure that data_ptr points to before making the comparison to threshold, and this line of code works.
If I had instead wanted to increment data_ptr before making the c...
I realized that I had some confusion regarding the value of a dereferenced pointer, as I was reading a C text with the following code snippet:
int main()
{
int matrix[3][10]; // line 3: matrix is tentatively defined
int (* arrPtr)[10] = matrix; // line 4: arrPtr is defined and initialize
(*arrPtr)[0]...
Season's greetings! I have a function that prints out the contents of a char** that is being used as an array to store a number of strings. The is declared like this:
char** commandArray = (char**)malloc(historySize);
where historySize is a global int set to 8, for now. The array is populated with commands that the user enters, in s...
Hi! Another newbie question:
Is there any way to check if a iterator (whether it is from a vector, a list, a deque...) is (still) dereferencable, i.e has not been invalidated ? If so, which is the best way, in your opinion? (I was 'trying' and 'catching' :/)
Thanks again!
Edit: An example (which doesn't work)
list<int>l;
for (i=1; i<...