in c and/or c++: is it safe to cast an int to void pointer and back to int again?
based on this question: http://stackoverflow.com/questions/3567905/c-is-it-safe-to-cast-pointer-to-int-and-later-back-to-pointer-again
...
I'm moving from C# to C++, one of priority topic for me is pointer. I'm reading some book and some blog post about pointer and I understand its basic concept. Now I want to learn about pointer by practicing it.
I try to search on google, unfortunately not thing found. Are there anything can help me study and practices on C++ pointer?
...
What exactly does this error message mean and how do I fix it?
.h
@property (nonatomic, retain) NSDictionary *defaults;
.m
...
Hi all,
I've been studying C++ for a test and I am currently stuck with pointer arithmetic.
The basic problem is the following:
int numColumns = 3;
int numRows = 4;
int a[numRows][numColumns];
a[0][0] = 1;
a[0][1] = 2;
a[0][2] = 3;
a[1][0] = 4;
a[1][1] = 5;
a[1][2] = 6;
a[2][0] = 7;
a[2][1] = 8;
a[2][2] = 9;
a[3][0] = 10;
a[3][1]...
Hi! :)
I have the following problem:
//A.h
class A
{
//...
// this is the important part, i have to call this in the proper way
// in A::SetNewValue(), but i don't know how to do that
protected:
void SetValue(const int* i);
//...
public:
// ??
void SetNewValue(const int* p);
}
the cpp:
//A.cpp
//??
A::SetNe...
C++: Using and returning character arrays from functions, return type or reference?
I'm trying to create a null terminated string outside of a function, then run a function which will assign some data to it. For example, char abc [80] is created in main. input() is then run, which will return user input to abc. I figure the two obviou...
Whats the difference between a Null pointer & a Void pointer?
...
So modern languages like perl, java, and C pass data around (function parameter for example) via pointers (if written correctly that is), so on the stack when you pass a variable in, the address of that variable is written. I was looking into old versions of fortran, before pointers, and was wondering: How was data passed around before p...
Hello,
I'm trying to define a path at compile time by passing:
-DDCROOTDEF='"/path/to/stuff"'
on the compile line. I then try to get use this in the code like:
char * ptr_path;
strcpy(ptr_path, DCROOTDEF);
strcat(ptr_path,"/MainCommons/CommonLib/fonts/Arial.ttf");
char *pftf=ptr_path;
gdImageStringFT(pimg,brect,iclr,pftf,pts,ang,i...
I have a tree structure and I want to find all nodes matching a given criteria. Each time I call the find function, it returns next matching node. Children are searched by recursive function call.
For some reason a key comparison of pointers fails for this implementation. Please see the code below, I have pointed out the failing compari...
I'm a C++ user and i started a few ago with C#, to be able to use XNA, because it makes really easy working with 2d textures and 3d models, so that i can forget a bit about that and just center in the game code.
The problem comes that I'm used to the pointers, so that my way of thinking the code usually makes use of some, and I couldn't...
I was curious how the StringBuilder class is implemented internally, so I decided to check out Mono's source code and compare it with Reflector's disassembled code of the Microsoft's implementation. Essentially, Microsoft's implementation uses char[] to store a string representation internally, and a bunch of unsafe methods to manipulate...
I have a C (not C++) struct that goes like this
typedef struct mystruct{
float a,b;
int x, y;
} mystruct;
Then in a function I collect data like this:
mystruct List[MAX];
ListNumber = 0;
for(i = 0; i < MAX; i++)
{
if(conditions_meet)
{
List[ListNumber].a = masterlist[i].a;
...etc
ListNumber++;
}
}
then I send the array to ...
I have a project im working on where I need to make an array that stores pointers but the number and size of the array will change at run time each time it runs. is there any way to declare variables in a for loop or something like that where i can declare a variable in the format of pointername with a number at the end.
...
Given a literal memory address in hexadecimal format, how can I create a pointer in C that addresses this memory location?
Memory addresses on my platform (IBM iSeries) are 128bits. C type long long is also 128bits.
Imagine I have a memory address to a string (char array) that is: C622D0129B0129F0
I assume the correct C syntax to dir...
So if I want to read some information at the offset 00A2E63C (e.g.)...
and I need to have it as a DWORD,
how can I convert the "00A2E63C" String to a proper DWORD?
help is appreciated
...
I want to copy a float buffer into a char (byte) buffer without allocating memory for two separate buffers. In another words I want to use one buffer and copy in place.
The Problem is that if I need a float buffer then in order to copy that to a char then I will need a char* pointer; If I were copying from float* to float* it would be ...
Hello, first(as always) I want to apologize about my english, it may not be clear enough.
I'm not that good at C programming, and I was asked to read a "string" input with undefined length.
This is my solution
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *newChar();
char *addChar(char *, char);
char *readLine(void...
$5.7 -
"[..]For addition, either both operands shall have arithmetic or enumeration type, or one operand shall be a pointer to a completely defined object type and the other shall have integral or enumeration type.
2 For subtraction, one of the following shall hold:
— both operands have arithmetic or enumeration type; or
— both operand...
I'm newbie. Pointer make my crazy T_T.
Now, I'm do the socket programming project.
This is my code.
typedef struct {
char *ip[INET6_ADDRSTRLEN];
char *username[20];
time_t login_time;
enum client_state client_state;
int no_login;
} Client;
Client client[max_connections] = {}; // set to nu...