Sponsored Content
Full Discussion: enumeration types in C
Top Forums Programming enumeration types in C Post 302224138 by cleopard on Tuesday 12th of August 2008 09:25:07 AM
Old 08-12-2008
enumeration types in C

If I want to declare an array of structures in C and have the number of items in that array to correspond to the items of an enumeration, is there a way to access the maximum value in the enumeration when declaring the array?

For instance:

typedef struct
{
various fields....
} fruit_rec;

enum fruit_info {apple, orange, banana}

fruit_rec fruits[3];


Instead of hard-coding a '3' in the 'fruits' declaration, is there a way I can access the number of items in the enumeration? In the old DoD language, Ada, one could do something like, " fruit_rec fruits[fruit_info] " .

I don't think there is a way to do what I'm asking, but I thought I'd ask as it would be a cleaner way of declaring things. Even if I can't do something like that, I know I can still refer to the elements as "fruits[apple}" , "fruits[orange]", etc. Thank you.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

servers types

dear sir , i would like to ask about sun solaries servers generations ? i hear about sparc and ultra . i want to know the versions , and is there other servers types ?? Thank (3 Replies)
Discussion started by: tamemi
3 Replies

2. UNIX for Dummies Questions & Answers

So many types of LINUX's!

I installed Redhat into my system. The reason? This was the version my friend was running and he told me about this one, so I downloaded and installed it. Simple enough :D But as I am searching the net, I am coming across many other forms of linux made by other companies. Redhat seems to be... (2 Replies)
Discussion started by: Minnesota Red
2 Replies

3. Programming

X-Windows Enumeration

Hi, I'm new to x-windows system and I have a few questions: 1. How can I write a C program to enumerate all the windows on the local and remote computers? In other words: How can I create a list of all the windows in the system (maximized/minimized/active/not active ....)? 2. How can I... (0 Replies)
Discussion started by: itaihoe
0 Replies

4. UNIX for Dummies Questions & Answers

Two types of pipes?

What is the difference between: cd /tmp tar -cf - *.txt |gzip > tmp_txt.tar.gz and cd /tmp mknod pipe p gzip < pipe > /tmp/tmp_txt1.tar.gz & tar -cf pipe *.txt Apart from the fact that we have to create the pipe file manually, is there any difference in the performance of the two?... (5 Replies)
Discussion started by: blowtorch
5 Replies

5. UNIX for Dummies Questions & Answers

mime types

Hi, I am trying to launch an ogg movie from a pdf file which has been produced with pdflatex and \movie {\centerline{\includegraphics {grafiques_xerrades/un_manolo_amb_camera.pdf}}} {hlims_xerrades/XocCumuls.ogg} The switch "externalviewer" makes kpdf launch the default... (5 Replies)
Discussion started by: pau
5 Replies

6. UNIX for Dummies Questions & Answers

Un-compression types...

Hi Folks, As I am familiar wih both types compresion forms: gun-zip and .rpm. My questions is how do I uncompress gunz.zip type? As the .rpm I can double click and it will extract...Can someone shed some light on this and thank you... M (2 Replies)
Discussion started by: Mombo_Z
2 Replies

7. What is on Your Mind?

What Types of Food Do You Like The Most?

On another simple topic, multiple choice answers OK ( you can pick more than one or suggest others - we will add your suggestions to the poll ). What Types of Food Do You Like The Most? (27 Replies)
Discussion started by: Neo
27 Replies

8. Shell Programming and Scripting

Cp -r except certain file types

the following excludes certain directories successfully cp -r probe/!(dir) /destination I want to exclude certain file types and tried unsuccessfully cp -r probe/!(*.avi) /destination (2 Replies)
Discussion started by: tmf
2 Replies
PEGASUS-DAX-VALIDA(1)													     PEGASUS-DAX-VALIDA(1)

NAME
pegasus-dax-validator - determines if a given DAX file is valid. SYNOPSIS
pegasus-dax-validator daxfile [verbose] DESCRIPTION
The pegasus-dax-validator is a simple application that determines, if a given DAX file is valid XML. For this, it parses the file with as many XML validity checks that the Apache Xerces XML parser framework supports. OPTIONS
daxfile The location of the file containing the DAX. verbose If any kind of second argument was specified, not limited to the string verbose, the verbose output mode is switched on. RETURN VALUE
If the DAX was parsed successfully, or only warning's were issued, the exit code is 0. Any 'error or fatal error will result in an exit code of 1. Additionally, a summary statistics with counts of warnings, errors, and fatal errors will be displayed. EXAMPLE
The following shows the parsing of a DAX file that uses the wrong kind of value for certain enumerations. The output shows the errors with the respective line number and column number of the input DAX file, so that one can find and fix them more easily. (The lines in the example were broken to fit the manpage format.) $ pegasus-dax-validator bd.dax ERROR in line 14, col 110: cvc-enumeration-valid: Value 'i386' is not facet-valid with respect to enumeration '[x86, x86_64, ppc, ppc_64, ia64, sparcv7, sparcv9, amd64]'. It must be a value from the enumeration. ERROR in line 14, col 110: cvc-attribute.3: The value 'i386' of attribute 'arch' on element 'executable' is not valid with respect to its type, 'ArchitectureType'. ERROR in line 14, col 110: cvc-enumeration-valid: Value 'darwin' is not facet-valid with respect to enumeration '[aix, sunos, linux, macosx, windows]'. It must be a value from the enumeration. ERROR in line 14, col 110: cvc-attribute.3: The value 'darwin' of attribute 'os' on element 'executable' is not valid with respect to its type, 'OSType'. 0 warnings, 4 errors, and 0 fatal errors detected. SEE ALSO
Apache Xerces-J http://xerces.apache.org/xerces2-j/ AUTHORS
Jens-S. Vockler <voeckler at isi dot edu> Pegasus Team http://pegasus.isi.edu/ 05/24/2012 PEGASUS-DAX-VALIDA(1)
All times are GMT -4. The time now is 02:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy