Hi, I'm messing around with multidimensional arrays and pointers. I've been looking at a program that prints out the contents of, and addresses of, a simple array. Here's my array declaration:
int zippo[4][2] = { {2,4},
{6,8},
{1,3},
{5,7} };
My current understanding is that zippo is a pointer, an...
I've always been taught that the more pointers you need in a piece of code, the less elegant it is. Also, I know that the only data structure that you 'need' is a singly linked tree. As a result, I've always tried my best to avoid such atrocities as doubly linked lists and doubly linked trees.
Is this true? Is code really inelegant if...
Hello All. I am having trouble accessing a declared property and I think I am missing something fundamental about the nature of properties and perhaps view controllers. Here's what I'm doing so far:
declaring a property "myPhone" in a root view controller called RootViewController.
grabbing a phone number from a modally presented peo...
So the question is whether or not string literals (or const strings) in Delphi 2009/2010 can be directly cast as PAnsiChar's or do they need an additional cast to AnsiString first for this to work?
The background is that I am calling functions in a legacy DLL with a C interface that has some functions that require C-style char pointers...
I'm looking at this program that reads input lines and then sorts them, from K&R.
And I can't figure out why it doesn't sort them correctly if I enter for example
1234532 first line
abc second line
It won't sort them in increasing order. Basically it doesn't work if the input lines contains numbers or something other then letters, I ...
hi ,
I've write a procedure which will store some data inside a structure and the I will pass the structure to other procedure like below
slotUpdate(Datas);
whereas I've defined the structure like :
someNameSpace::stuData Datas;
after passing the structure to slotUpdate again I'll pass it to another procedure but this time as a pa...
The following code crashes on the second Pop() call. I'm a novice with C and I've been staring at this code now for over an hour and i can't see the error. Any ideas to help me out on why this code is crashing?
#include <stdio.h>
#define StackDataSize 100
typedef struct Stack
{
int index;
void *data[StackDataSize];
} Stack;
v...
I'm not experienced with java applications but I found out that finding static pointers etc. to these applications' memory addresses is often (nearly) impossible, apparently because of the java engine that handles the code (correct me if this way of naming it is wrong please).
Now, I've used VisualVM (https://visualvm.dev.java.net/) and...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 1000
int getline(char *s, int lim)
{
int i = 0;
while(i < lim - 1 && (*s = getchar()) != EOF && *s++ != '\n')
i++;
if(*s == '\n')
*s++ = '\n', i++;
*s = '\0';
return i;
}
int main(int argc, char *argv[])
{
char line[MA...
I have a function which operates on piece of data (let's say, an int), and I want to change it in place by passing a reference to the valule. As such, I have the function: void myFunction(int *thing) { ... }. When I use it I call it thus: myFunction(&anInt).
As my function is called frequently (but from many different places) I am conc...
Possible Duplicate:
Why does C have a distinction between -> and . ?
Lets say that I have this structure:
struct movies
{
string title;
int year;
} my_movie, *ptrMovie;
Now I access my_movie like this: my_movie.year = 1999; Now to access a pointer I must do this: ptrMovie->year = 1999;
Why do pointers use the -> oper...
Hi All,
Anybody out there who had developed plugins for eclipse?
I am using eclipse for last 4-5 years and am just thinking about developing some plugins for eclipse. I dont know anything about that, like how its written and all. If someone who has experience on this can show light over that, it would be great. Some really good tutorial...
Hi all,
Wrote a very simple C function to illustrate what I would like to simplify:
void main(int argc, char *argv[]){
char *me="Foo";
char *you="Bar";
char us[100];
memset(us,100,0x00);
sprintf(us,"You: %s\n",you);
sprintf(us+strlen(us),"Me: %s\n",me);
sprintf(us+strlen(us),"We are %s and %s!\n",me,you);
...
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define TAB_STOP 8
/* replaces tabs from input with the proper amount of blank spots */
int Detab()
{
int c, x;
int column;
x = column = 0;
while((c=getchar())!=EOF)
{
if(c == '\n') /* reseting counter if newline */
{
putchar(...
hi!
foo1(int* val){(*val)++;}
foo2(int &val){val++;}
will the compiler create in both cases the same code? will it simply write a pointer into the parameterpart of foo's stackframe? or will in the second case the callers' and foos' stackframes somehow overlap such that the callers' local variable takes the same memory on the stack as...
Is there a difference between Move and CopyMemory in Delphi(specifically versions 2007 and up)?
If so, what are the differences?
...
when implementing a heap structure, we can store the data in an array such that the children of the node at position i are at position 2i and 2i+1.
my question is, why dont we use an array to represent binary search trees and instead we deal with pointers etc.?
thanks
...
I had a question regarding the use of asterisks in Objective-C. Just to be clear: I understand what pointers are and everything in procedural C. I was wondering two things though:
1) Why are all (references to) Objective-C objects pointers? Why not plain variables? (i.e. NSArray array = [[NSArray alloc] init];)
2) Why do you omit the a...
Hi,
In the following rules for the case when array decays to pointer:
An lvalue [see question 2.5] of type array-of-T which appears in an expression decays (with three exceptions) into a pointer to its first element; the type of the resultant pointer is pointer-to-T.
(The exceptions are when the array is the operand of a sizeo...
#include <stdio.h>
#include <string.h>
#define MAXLINES 5000
char *lineptr[MAXLINES];
int readlines(char *lineptr[], int nlines);
void writelines(char *lineptr[], int nlines);
void qsort(void *lineptr[], int left, int right, int (*comp)(void *, void *));
int numcmp(char *, char *);
int main(int argc, char *argv[])
{
int nlines;
...