Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2000:
[Freeciv-Dev] Re: OO model for Freeciv?
Home

[Freeciv-Dev] Re: OO model for Freeciv?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: OO model for Freeciv?
From: 蔡恆華 <iquin@xxxxxxxxxx>
Date: Mon, 1 May 2000 22:13:51 -0400 (EDT)

>s += '.';
>
>What is the shortest way to express this in C?
s = strcat((char *)realloc(s , strlen(s) + 1), ".");
Convenience sometimes makes programmers unaware of the underlying
costs, results in less efficient codes.
Anybody know how to do this with g++?
enum tile_terrain_type {
  T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE,
  T_MOUNTAINS, T_OCEAN, T_PLAINS, T_RIVER, T_SWAMP, T_TUNDRA, T_UNKNOWN,
  T_LAST
};

char terrain_char[T_LAST] = {
  [T_MOUNTAINS] 'm', [T_GRASSLAND] 'g', [T_UNKNOWN] 'u', [T_TUNDRA] 't',
  [T_PLAINS] 'p', [T_JUNGLE] 'j', [T_FOREST] 'f', [T_DESERT] 'd',
  [T_ARCTIC] 'a', [T_SWAMP] 's', [T_RIVER] 'r', [T_OCEAN] 'o', [T_HILLS] 'h',
};

Thanks.

Regards,
I.Q.
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup




[Prev in Thread] Current Thread [Next in Thread]