473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Structures with Pointers question

Hi, Does anyone know how i can store the address of a particular node ie. "startPointer ". This variable will store the address of a node so that that i can call out to the node when i need it in any of my functions. My code will have no problem if I declare the startPointer variable globally. But the problem now is that based on my assignment req, I'm not allowed to declare any variables global other than the specified ones.

struct data
{
double xstart, xend, ystart, yend; //get xstart,xend,ystart,yend values
int child, iter, width, height; //get iteration value
data* next; //pointer to next node
};data* startPointer ;
...
...
main(){...

Is there any way that I could get around this to declare it inside main()? My coded doesn't work if i use it in main()

Thanks.
Jul 27 '06 #1
1 1380
Banfa
9,065 Expert Mod 8TB
But the problem now is that based on my assignment req, I'm not allowed to declare any variables global other than the specified ones.
What are the specified ones?

Declare your start pointer in main, pass a pointer to it to all sub-functions.

Expand|Select|Wrap|Line Numbers
  1. struct data
  2. {
  3. double xstart, xend, ystart, yend; //get xstart,xend,ystart,yend values
  4. int child, iter, width, height; //get iteration value
  5. data* next; //pointer to next node
  6. };
  7.  
  8. static SomeFunction( data **pStartPointer, int SomeOtherParameter);
  9.  
  10. main()
  11. {
  12.     data *startPointer;
  13.  
  14.     startPointer = malloc(sizeof *startPointer);
  15.  
  16.     SomeFunction( &startPointer, 7);
  17. }
  18.  
  19. static SomeFunction( data **pStartPointer, int SomeOtherParameter)
  20. {
  21.    (*pStartPointer)->width = SomeOtherParameter;
  22. }
  23.  
  24.  
Jul 27 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Fred Bennett | last post by:
I have a simulation project in which data can naturally be held in structures for processing. There are calls to multiple functions involved. Execution speed is an issue. Do I take a big hit for...
1
by: kazack | last post by:
Hi all it's me again with another question as I got further in my book. The chapter I am in covers structres, abstract data and classes. I only read through to the end of the coverage on...
7
by: Squignibbler | last post by:
Hi all, I have a question regarding the C++ programming language regarding the nature of the relationship between pointers and arrays. If the statement MyArray is functionally identical to...
11
by: Bradford Chamberlain | last post by:
I work a lot with multidimensional arrays of dynamic size in C, implementing them using a single-dimensional C array and the appropriate multipliers and offsets to index into it appropriately. I...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
8
by: Frank Münnich | last post by:
Hi there.. My name is Frank Münnich. I've got a question about pointers that refer to an array of a structure. How do I declare that type? If I have declared a structure struct mystruc {...
4
by: Skybuck Flying | last post by:
Hello, I have a question about the C language. This piece of code is from the glibc library. My question is about the static struct The question is....
6
by: Sam | last post by:
Hi everyone I'm confused by these declarations: struct hostent *he; server *s = (server*)malloc(sizeof(server)); /* in the code * he = gethostbyname(name);
11
by: Alfonso Morra | last post by:
Hi, I have the ff data types : typedef enum { VAL_LONG , VAL_DOUBLE , VAL_STRING , VAL_DATASET }ValueTypeEnum ;
8
by: Bob Altman | last post by:
Hi all, I have a structure that includes a constructor. I want to add a bunch of these structures to an STL map (whose index is an int). If I define the map like this: map<int,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.