------------------------------------------------------------------------------
MC logo
Typedef
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Enumerated Type] [Typedef] [Unsigned Type] [Conversion Games]
typedef.c
/* C typedef assigns a name to a type.  Its syntax can be really awful. */
#include <stdio.h>

/* Make fred an alias for the type name integer. */
typedef int fred;

/* Assign a type name to an enumeration. */
typedef enum { Sun, Mon, Tue, Wed, Thu, Fri, Sat} day;

int main()
{
        fred m = 5;
        day today = Fri;

        if(today == m) printf("Yes!\n");
        else printf("Nope.\n");
}