Solved

pointer to the structure

Posted on 2003-10-23
4
183 Views
Last Modified: 2010-04-17
I am a srudent just having question related to  C++..... I have a file(programm)which reads the data from xml file,now i would like to put the data into the structure with different variable (like char,int,etc)by using the pointer to the whole structure,then would like to creat instances(objects)for further execution.Can u guide me how can I do all this with an example.
0
Comment
Question by:syed110
4 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 75 total points
ID: 9606283
Hi syed110,

suppose you have
struct a {
   int b;
   char c;
   int d;
};

struct a * p;
struct a st;

p = &st;

to store values in this struct using the pointer

p->b = 10;
p->c = 'a';
p->d = 25;

replace the RHS values with the values you have read from the file

Cheers!
Sunny:o)
0
 
LVL 3

Expert Comment

by:yasser_helmy
ID: 9616288
What objects are you talking about? do you have objects containing the structures?
0
 
LVL 1

Expert Comment

by:logicTRANCE
ID: 9623476
And if u want to create an instance of the structure at runtime, after creating the pointer variable p,

p=new (struct a);

Goodluck!
Happy Programming!
0
 

Author Comment

by:syed110
ID: 9648686
ok thanx
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now