Solved

pointer to the structure

Posted on 2003-10-23
4
185 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

776 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