Array of a type

From: Profetas (xuxu_18_at_yahoo.com)
Date: 05/02/04


Date: Sun, 02 May 2004 11:37:04 -0400

I have to do a program that determine the biggest
number in the month

I have to use enum
so I was wondering can I declare an array of a type
like

#include <stdio.h>

int main()
{
int h_rain_fall, n_months, i;
enum months {jan=23, feb=19, apr=27, mar=38, may=33, jun=24, jul=20,
aug=18, sep=26, oct=30, nov=26, dec=22};
string a_months[jan,feb,apr,mar,may,jun,jul,aug,sep,oct,nov,dec];
n_months = 12;
i = 0;

for(i=n_months; i!=0 ; i--) {

  printf("teste %d", a_months[i]);
   if (a_months[i] > h_rain_fall)
    {
     h_rain_fall = a_months[i];
     }
    else
     {
       //skip
     }
}
printf("The highst rain fall is %d",h_rain_fall);
return(0);
}

Thanks Profetas



Relevant Pages

  • Re: Newbie Question
    ... It may be a problem but the compiler error clearly stated that he tried to ... declare a method where only a class, delegate, enum, interface, or struct is ... >> public static extern int SendCharFmtMsg(IntPtr hWnd, int Msg, int ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Trying to understand enums
    ... that's the name of the enum value. ... They are a way to declare new, ... constant types as an int. ... integer base type, it's true that you can do a lot of integer-like things   ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Array of a type
    ... Profetas wrote: ... > I have to do a program that determine the biggest ... > I have to use enum ... int main ...
    (comp.lang.c)
  • Re: Trying to understand enums
    ... Enums aren't supposed to be a way to declare integer constants. ... If you want a constant typed as an int, then declare a constant types as an int. ... Because they are little more than a thin, type-safe veneer on top of an integer base type, it's true that you can do a lot of integer-like things with them, and of course can even cast to and from integer types. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: enum <name> : int {} - requires cast to int??
    ... > Of course if I cast int to it, then it compiles, but if I have declared the ... enum Foo: int is just syntactical sugar. ... It doesn't declare a true "int" subclass, ...
    (microsoft.public.dotnet.languages.csharp)