Solved

pointer to the structure

Posted on 2003-10-23
4
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Introduction to Processes

627 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