I was wondering if somebody could explain me how pointers and string parsing works. I know that I can do something like the following in a loop but I still don't follow very well how it works.
for (a = str; * a; a++) ...
For instance, I'm trying to get the last integer from the string. if I have a string as const char *str = "some...
Possible Duplicate:
C: How come an arrays address is equal to its value?
SA
In C I tried to print the address of the pointer of an array.
int a[3] = {0,1,2};
printf("\n%p",a);
printf("\n%p",(&a));
the 2 statement prints the same value why?thanks in advance
...
Hello, I'm using ptr_map from boost for storing objects derived from some base abstract type.
class Entity { virtual void foo() = 0; };
class Entity1 : public Entity {};
class Entity2 : public Entity {};
boost::ptr_map<string, Entity> someMap; // We could store pointers for abstract type
Inserting works great:
someMap.insert("someKe...
Using Glib Testing framework, I would like to know if I can reuse a pointer queued to be freed with g_test_queue_free?
Here's a code sample of what I'm trying to do:
static void some_test()
{
gchar* tmp;
tmp = func_returning_gchar_ptr (...params...);
g_assert(tmp);
g_test_queue_free(tmp);
tmp = func_returning_gchar_ptr (......
char *str = "Hello";
char *ptr = str;
char *&rptr = str;
What is the difference between ptr and rptr? I understand rptr is a reference to a pointer(in theory) but how does it differ in terms of implementation with ptr?
Are references in C++ implemented using pointers?
...
I have some code that looks like this:
Thread 0:
CMyOtherClass *m_myclass;
CMyClass::SomeFunc(DWORD SomeParam)
{
m_myclass = new CMyOtherClass(SomeParam);
}
Thread 1:
CMyClass::InsideSecondThread()
{
MySecondThreadFunc(*m_myclass);
}
CMyClass::MySecondThreadFunc(MyOtherClass& myclass)
{
// do something with myclass varia...
Hi,
I try to pass a pointer of a structure which is given me as a return value from the function 'bar' to the function 'foo_write'. But I get the error message 'TypeError: must be a ctypes type' for line 'foo = POINTER(temp_foo)'. In the ctypes online help I found that 'ctypes.POINTER' only works with ctypes types. Do you know of anothe...
Hello, I'm using ptr_map for storing different types of pointers.
boost::ptr_map<string, any> someMap;
I store there some templated class objects:
someMap.insert("1", new SomeClass<int>());
someMap.insert("2", new SomeClass<float>());
Now I want to get values from map. Here is a sample with references:
template<typename T>
T &get(...
I'm running into a VERY frustrating pointer issue. I previously posted here:
http://stackoverflow.com/questions/3114997/tough-dealing-with-deeply-nested-pointers-in-c
But that post got overly long and is stale, so I chose to repost with more details.
Here is my header file that defines my types:
#include <string>
#include <vector>
#i...
Hi there,
I'm having some trouble with a program that is intended to be a String buffer, specifically this function is intended to reset the buffer with the string cstr. If cstr is null then the content needs to be reset to an empty char '\0'. It always hangs at the second set of realloc where it's resizing buf->contents I have no clue w...
Hi, still working at C++, but this came up in my book and I don't understand what it's for:
MyClass * FunctionTwo (MyClass *testClass) {
return 0;
}
My question is what is the signifigance of the first indirection operator
(MyClass *[<- this one] FunctionTwo(MyClass *testClass))?
I tried making a function like it in codeblocks...
I'm having troubles when calling a function taking a pointer to a string as a parameter. I need to get an Element's name.
// method
void getStringFromCsv( char ** str );
Let me introduce the structures I'm working with (not written by me and part of a much bigger project, I can't modify them).
// typedefs
typedef char T_CHAR64[...
Hello,
In a C# project, I need to pass object parameters by putting references in a structure.
i.e. I have a structure passed to a dispatcher
struct SOMESTRUCT
{
public int lpObject;
}
Where lpObject holds a pointer to a custom object like
class SomeClass
{
private string foo;
}
And the SOMESTRUCT structure is passed from ...
Visual Studio debugger automatically recognizes the types of pointers and shows the value of the variable or object pointed to by the pointer. Example screenshot for Ruby debugger here: http://www.rubyinside.com/wp-content/uploads/2008/03/jruby-debugger.jpg This applies to debugger tooltips, watch windows, etc. I never have to see t...
Possible Duplicate:
Whats your preferred pointer declaration style, and why?
Just curious: What's you standard method when declaring pointers? Why?
SomeClass *instance;
OR
SomeClass* instance;
I prefer the second method as it keeps the entire type together (it's a 'SomeClass pointer'). But I know many prefer the first an...
Is there any way to malloc a large array, but refer to it with 2D syntax? I want something like:
int *memory = (int *)malloc(sizeof(int)*400*200);
int MAGICVAR = ...;
MAGICVAR[20][10] = 3; //sets the (200*20 + 10)th element
UPDATE: This was important to mention: I just want to have one contiguous block of memory. I just don't want to...
Possible Duplicate:
Take the address of a one-past-the-end array element via subscript: legal by the C++ Standard or not?
int array[10];
int* a = array + 10; // well-defined
int* b = &array[10]; // not sure...
Is the last line valid or not?
...
Hi, I have this function:
char* ReadBlock(fstream& stream, int size)
{
char* memblock;
memblock = new char[size];
stream.read(memblock, size);
return(memblock);
}
The function is called every time I have to read bytes from a file. I think it allocates new memory every time I use it but how can I free the memory once I ...
I'm trying to add functionality to the v8sharp project and I'm having some issues (I'm not very good at C++ so I'm pretty sure the issue lies in my lack of C++ abilities rather than misusing v8.)
Anyone in v8sharp we have this code
v8value.cpp:
v8sharp::V8FunctionWrapper^ V8ValueWrapper::WrapFunction(v8::Handle<v8::Value> value) {
...
Hi.
I have to create a 3-Dimensional array, wich gets allocated at object creation. I've done such stuff before with normal arrays.
typedef unsigned char byte; // =|
byte ***data;
...