I understand passing a pointer, and returning a pointer:
char * strcat ( char * destination, const char * source );
You're passing a variable that contains the address to a char; returning the same.
But what does it mean to pass something using the reference operator? Or to return it?
string& insert ( size_t pos1, const string& str ...
Possible Duplicate:
Testing pointers for validity (C/C++)
If I have a pointer, like char* foo, is there any way to determine if foo points to a valid location in memory? (So, foo is not NULL, and delete has not yet been called on it.)
...
Possible Duplicates:
Why use pointers?
Passing a modifiable parameter to c++ function
Why would I want to have pointer parameters? The only reason I can see is for small functions to attempt to reduce confusion and a smaller memory footprint.
...
Ok, I know this question seems to have been asked many times on stackoverflow.
but please read
Well the answer for any address is "No you can't" but the question here is to know if a pointer points to a piece of memory allocated with malloc/new.
Actually I think it could be easily implemented overriding malloc/free and keeping track of ...
Hi there,
I was wondering if there is a possibility to catch errors like this in C++:
object* p = new object;
delete p;
delete p; //this would cause an error, can I catch this?
Can I check if the pointer is valid?
Can I catch some exception?
I know I could set the pointer p to NULL after the first object deletion. But just imagin...
Hi there,
I am writing swig bindings for some c functions. One of these functions takes a float*. I am already using cpointer.i for the normal pointers and looked into carrays.i, but I did not find a way to declare a float*. What do you recommend?
interface file:
extern int read_data(const char
*file,int *n_,int *m_,float **data_...
I have a python Interpreter written in C++, the PyRun_String function from the Python API is said to return a handle, however in my code I have it assigned to pointer to a PyObject?
PyObject* presult = PyRun_String(code, parse_mode, dict, dict);
Is this actually correct? Can you implicitly cast this handle to this object pointer?
S...
Hi,
after having no success with my question on How to use float ** in Python with Swig?, I started thinking that swig might not be the weapon of choice. I need bindings for some c functions. One of these functions takes a float**. What would you recomend? Ctypes?
Interface file:
extern int read_data(const char *file,int *n_,int *m_,f...
Hi,
I came accross a code snippet which detects whether app is running in x32 emulated environment on x64 PC here
Generally I understand that code but there is one thing I don't get:
1) typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
Why does WINAPI have to be there? Why is it so important to know that pointer doesn't p...
I'm writing an expression tree.
The Node class has instances of itself as members left, right and parent.
Thanks to James McNellis in this post, I declared them as pointers.
class Node
{
public:
char *cargo;
int depth;
Node *parent;
Node *left;
Node *right;
//constructors/destr...
Hey guy,
I'm writing a NES emulator in C/C++ for Mac OS (I've already written one, so I know the basics). Since many hardware registers are mapped to memory locations, I was wondering if there was some syscall I could use to map an address to the result of a function: when it would be accessed, the function would be called. (I'm pretty ...
Possible Duplicate:
How do pointer to pointers work in C?
Hello,
Altough I think I passed the newbie phase in programming I still have some questions that somehow I can't find them explained. Yes, there are plenty of "how to"s overthere but almost always nobody explains why and/or when one technique is useful.
In my case I h...
i have a dynamically made prototype:
typedef double ICEDouble;
-(BOOL) getPosition:(SyDRpcInterfacePositionType)type longitude:(ICEDouble *)longitude latitude:(ICEDouble *)latitude;
and i would call it so, because i have no plan, how to do it in the right way:
NSNumber* longitudeReturn;
NSNumber** latitudeReturn;
[prx getPositi...
Hi, I have a pointer (uint8_t *myPointer), that I pass as paramether to a method, and then this method set the value to this pointer, but I want to know how much bytes are used (pointed ?) by the myPointer variable.
Thanks in advance and excuse me by my english.
...
I'm trying to access the object (called a Vector) pointed to by a pointer held in a vector container, but I can't seem to get to it.
Here are the important code snippets:
int main{
Vector<double>* test = new Vector<double>(randvec<double>());
test->save();
cout << Element::vectors[0];
return 0;
}
Where Vector is a templ...
This is driving me crazy:
I have function
void gst_init(int *argc, char **argv[]);
in the gstreamer api and I want to call it with some parameters I define, like:
int argc = 2;
char* argv[2] = {"myvalue1", "myvalue2"};
gst_init(&argc, &argv);
This code doesn't compile (I get error C2664):
error C2664: 'gst_init' : cannot convert...
Hello,
I am really confused by pointers... I guess I am used to other languages that do not have them. I have the following snippet of code:
- (void)setAccountNumber:(NSString *)accountNumber Pin:(NSString *)pin {
myAccessNumber.text = accountNumber;
myPin.text = pin;
}
This function is being called by another view before this vie...
in c++ ..
first of all I need to make a constructor of class Date d() that creates the current date.. what should i do?
after that i have a problem with this program:
class Noleggio
{
public:
//Noleggio(unsigned f, unsigned n, unsigned c) : inizio() { film = f; copia = n; cliente = c; restituito = false; }
bool restituito;...
Hello, I am working with an application in C# that need to send a message to a C++ application.
I imported
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(
int hWnd, // handle to destination window
uint Msg, // message
IntPtr wParam, // first message parame...
I am trying to expose a C++ library to python using boost-python. The library actually wraps an underlying C api, so uses raw pointers a lot.
// implementation of function that creates a Request object
inline Request Service::createRequest(const char* operation) const
{
blpapi_Request_t *request;
ExceptionUtil::throwOnError(
...