I have a 3x3 array that I'm trying to create a pointer to and I keep getting this array, what gives?
How do I have to define the pointer? I've tried every combination of [] and *.
Is it possible to do this?
int tempSec[3][3];
int* pTemp = tempSec;
...
I have set up the following struct:
typedef struct _thread_node_t {
pthread_t thread;
struct thread_node_t *next;
} thread_node_t;
... and then I have defined:
// create thread to for incoming connection
thread_node_t *thread_node = (thread_node_t*) malloc(sizeof(thread_node_t));
pthread_create(&(thread_node->thread), NULL, c...
typedef struct
{
uint32 item1;
uint32 item2;
uint32 item3;
uint32 item4;
<some_other_typedef struct> *table;
} Inner_t;
typedef struct
{
Inner_t tableA;
Inner_t tableB;
} Outer_t;
Outer_t outer_instance =
{
{NULL},
{
0,
1,
2,
3,
table_defined_somewhere_else,
}
};
My question i...
I have a struct defined with the structure as follows (names are different)
struct str1
{
int field1;
struct str2;
}
And I have a *str1 in a function. I'd like to get a pointer to str2.
So I tried &(str1->str2) and was hoping this would return a pointer to str2. Is this incorrect? It doesn't seem to be working. How would I get ...
Hello, I am seeking to improve my C++ skills by writing a sample software renderer. It takes objects consisting of points in a 3d space and maps them to a 2d viewport and draws circles of varying size for each point in view. Which is better:
class World{
vector<ObjectBaseClass> object_list;
public:
void generate(){
objec...
Greetings,
My project structure is as follows:
\- base (C static library)
callbacks.h
callbacks.c
paint_node.c
.
.
* libBase.a
\-app (C++ application)
main.cpp
In C library 'base' , I have declared global-function-pointer as:
in singleheader file
callbacks.h
#ifndef CALLBACKS_H_
#define CALLBA...
Code snippet (normal pointer)
int *pi = new int;
int i = 90;
pi = &i;
int k = *pi + 10;
cout<<k<<endl;
delete pi;
[Output: 100]
Code snippet (auto pointer)
Case 1:
std::auto_ptr<int> pi(new int);
int i = 90;
pi = &i;
int k = *pi + 10; //Throws unhandled exception error at this point while debugging.
cout<<k<<endl;
//delete pi; (It...
I am not sure how to approach this problem:
'Player' class mantains a list of Bullet* objects:
class Player
{
protected:
std::list< Bullet* > m_pBullet_list;
}
When the player fires a Bullet, it is added to this list. Also, inside the constructor of bullet, a reference of the same object is updated in CollisionMgr, where Collisio...
#!/usr/bin/env perl
use warnings;
use strict;
use 5.012;
use XML::LibXML::Reader;
my $reader = XML::LibXML::Reader->new( location => 'http://www.heise.de/' ) or die $!;
while ( $reader->read ) {
say $reader->name;
}
At the end of the output from this script I get this error-messages:
* glibc detected * perl: munmap_chunk(): ...
Hi guys,
Question is how do i convert a pointer to int to an actual int
I dont know if this is possible or not, but can someone please advise me
Regards
Paul
...
I noticed this situation in my code (unfortunately), and was able to duplicate it in my own JS file. So I have this code:
var date1 = new Date(); // today
var date2 = date1;
date2 = date2.setDate(date2.getDate() + 1);
// what is date1?
After this code executes, date1 is today's date + 1! This harkens back to my undergrad days when I...
Hi there, I have the following code
struct Node {
int accnumber;
float balance;
Node *next;
};
Node *A, *B;
int main() {
A = NULL;
B = NULL;
AddNode(A, 123, 99.87);
AddNode(B, 789, 52.64);
etc…
}
void AddNode(Node * & listpointer, int a, float b) {
// add a new node to the FRONT of the list
Node *temp;
temp = new ...
Suppose I have the following struct and function returning a pointer:
typedef struct {
int num;
void *nums;
int size;
} Mystruct;
Mystruct *mystruct(int num, int size)
{
//Is the following correct? Is there a more efficient way?
Mystruct mystruct;
mystruct.num = num;
mystruct.size = size;
mystruct.nums = malloc(nu...
Hello, in C++, the following means "allocate memory for an int pointer":
int* number;
So, the asterisk is part of the variable type; without it, that would mean something else (that's why I usually don't separate the asterisk from the variable type). Then what is the reason the asterisk is considered something else, instead of being p...
In F#, there's the NativePtr module, but it seems to only support 32 bit offsets for its’ add/get/set functions, just like System.IntPtr does.
Is there a way to add a 64 bit offset to a native pointer (nativeptr<'a>) in F#? Of course I could convert all addresses to 64 bit integers, do normal integer operations and then convert the resu...
I have a C++ string. I need to pass this string to a function accepting char* parameter,
for example - strchr().
a) How do I get that pointer?
b) Is there some funtion equivalent to strschr() that works for C++ strings?
...
I have this a class called PPString:
PPString.h
#ifndef __CPP_PPString
#define __CPP_PPString
#include "PPObject.h"
class PPString : public PPObject {
char *stringValue[];
public:
char *pointerToCharString();
void setCharString(char *charString[]);
void setCharString(const char charString[]);
};
#endif
PPString.cpp...
Is there a way to have a bit bucket pointer?
A lot of IO (specifically input related) system calls return data to a buffer of a specific size. Is there a trick or way to make a sorta bit bucket pointer, so I can accept any amount of data that will be thrown away. Doing something like "char tmp[INT_MAX]" is crazy. The behavior I am looki...
How can the below code result in a dangling pointer.
{
char *cPointer = malloc ( some constant number );
/* some code */
free ( cPointer );
cPointer = NULL;
/* some code */
}
...
In the many search functions of C (bsearch comes to mind) if a result is found, a pointer to the spot in the array is returned. How can I convert this pointer to the index in the array that was searched (using pointer arithmetic, i assume).
...