Tagged: Structures

0

Programming in C: Typedef

What if ther was a way to name a certain type, and then use that name across your program?  That way, if that particular type needed to be changed, say to be an int instead of a char, you could specify that in one place.  Well, that’s where the typedef  statement comes in. However, typedef’s can be a mixed bag, if used too much you acquire obfuscation in your code, but if used to little, you may end up having to edit your code in multiple places; or you may end up with code whose purpose is difficult to understand.

1

Programming in C: Structures

Structures are ways to encapsulate related data, presumably, under one data type.  This allows us to organize data that is related to each other into one place.  Otherwise, all of our data would have to exist in separate variables, and as we programmed we’d have to remember how it call connected ourselves.  This is truly prone to drastic error, and memory wise is convoluted.