LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-19-2005, 02:16 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Rep: Reputation: 45
array of unions in c


Hi lets suppose that we declare an array of unions'

union{
long lala;
int myint;
char mychar[30];
}myunion[40];

Is is possible to do the following
myunion[1].lala=323434243;
strcpy(myunion[2].char,"shit);
and so on?
 
Old 09-19-2005, 03:07 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,490

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Just try it, that's the best way to learn.
 
Old 09-19-2005, 03:48 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Original Poster
Rep: Reputation: 45
i have tried it and i think it works but still i am not sure
 
Old 09-19-2005, 09:02 AM   #4
addy86
Member
 
Registered: Nov 2004
Location: Germany
Distribution: Debian Testing
Posts: 332

Rep: Reputation: 31
You have 1200 posts, probably most of them programming-related, but still don't know the basics about arrays and unions? And even more, it works, but you're not sure whether it works?

I hope I didn't hurt you...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
array c++ harrylee2003 Programming 3 10-14-2005 05:04 PM
array of unions (c code) alaios Programming 6 09-16-2005 11:43 AM
structres and unions problem linux_lover2005 Programming 2 04-15-2005 08:31 AM
PERL: Size of an array of an Array inspleak Programming 2 03-10-2004 02:24 PM
2-D Array clowns119 Programming 10 09-24-2003 10:15 PM


All times are GMT -5. The time now is 09:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration