Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

pointer to the structure

Posted on 2003-10-23
4
Medium Priority
?
201 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 225 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Simple Linear Regression
Loops Section Overview

782 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