CSC209H5 Chapter Notes - Chapter 6: Compile Time

38 views2 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Allows you to define an alias for a type and is evaluated at compile time. # include typedef unsigned int size_t ; typedef unsigned int age_t ; typedef unsigned int show_size_t ; typedef struct student { char first_name[ 20 ]; char last_name[ 20 ]; int year; float gpa; } student; void print_boot_size ( shoe_size_t shoe_size) { printf ( "boot size: %d\n" , shoe_size + 2 ); int main () { age_t my_age = 5 ; print_boot_size(my_age); print_boot_size( "5" ); Typedef allows you to define a name, in this case size_t , that refers to an existing type, unsigned int. You are not creating a new composite type with components with their own names (similar to struct), you are providing a new name for an existing type. When you see the shoe_size_t, you may not know how to necessarily use it.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents