Solved

union inside struct, how to access it?

Posted on 2008-10-15
7
1,285 Views
Last Modified: 2008-10-16
If I have :

how do I access the char* text, inside the union of a struct? in typ?
struct data {
     int type;
     union {
        char* text;
        char* charcon;
	 char* id;
        int val;
     } d;
   } typ;

Open in new window

0
Comment
Question by:kuntilanak
  • 4
  • 3
7 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 22725453
You'd use typ.d.text to access it.
0
 

Author Comment

by:kuntilanak
ID: 22725465
ok, thanks.. can you get to my other question about the symbol table?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22725548
I was already on it ;)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:kuntilanak
ID: 22725616
thanks, hope you can reply faster :)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22725736
>> hope you can reply faster :)

That all depends on my availability heh. It's quite late here, and I'll head to bed soon to get up early tomorrow and go to work :) But I do my best.
0
 

Author Comment

by:kuntilanak
ID: 22725783
You're really a bunch of help really.. If I could reward you with 10k points, I would do it right now..
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22726214
No worries. I'm just glad I can help out :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

839 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