From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Exploring unary operators

Exploring unary operators

- [Instructor] The C Language unary operators affect only one variable. The name unary comes from the Latin unes, one. Here's the full list, including the sizeof operator, which is both an operator and a C language keyword. It deserves a bit of exploration. Sizeof works on a variable, array or a chunk of memory. It returns a size_t value, which is an unsigned positive integer, representing the number of bytes of memory the item occupies. You must include the stdio.h header file to use the size_t typedef in your code, the operator's used most often when allocating memory or dealing with pointers. In this code, six variables are declared, the four standards, char and float and double. I've also created a character array or string, and an integer array capable of holding 10 elements. For each of these items, a printf statement outputs the size they occupy in memory. Within the printf statement, the size of operator is applied to each variable or data type. The values shown here might not…

Contents