[techtalk] switch function in C (or how to read commandline args?)

Jeff Dike jdike at karaya.com
Sat Jun 30 22:02:23 EST 2001


jenn at simegen.com said:
> It doesn't have to be an int, but the 'case' statements need
> constants.

> I hope this helps. 

C considers "foo" to be a string constant, but you can't (or at least 
shouldn't) use it as a case.

Case statements need constants that are 'int-like' :-)  An "integral constant 
expression" according to the ANSI standard.  char, short, long, long long, 
enums, and signed and unsigned variants of the above.  But no strings, floats, 
or doubles.

				Jeff






More information about the Techtalk mailing list