Solved

pointer to the structure

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 …

829 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