CIS 1500 Lecture Notes - Lecture 18: Semicolon

24 views4 pages

Document Summary

Typedef typedef is how you give aliases to things in c. similar to #define but not quite. They can help make code more readable example: typedef unsigned int uint; uint mynum = 2000; You can typedef basically anything so be careful and sensible. Don"t be cute. typedefs are often used with structs. Structs: a structure is a programmer-defined data type. Example: struct date { int day; int month; int year; Structures can be statically allocated (from the stack) just like other variable types. /* structure definition */ struct date { int day; int month; int year; int * ptr; /* structure allocation */ int main(void) { struct date birthday; birthday. day = 15; birthday. month = 11; birthday. year = 1800; birthday->ptr = 2; The dot operator is used to access regular components of a structure. If your struct has a pointer variable type, the access operator changes to the -> operator.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents