

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
size_t data type in C
The datatype size_t is unsigned integral type. It represents the size of any object in bytes and returned by sizeof operator. It is used for array indexing and counting. It can never be negative. The return type of strcspn, strlen functions is size_t.
Here is the syntax of size_t in C language,
const size_t var_name;
Here,
var_name − This the name of variable.
Here is an example of size_t in C language,
Example
#include <stdio.h> #include <stddef.h> #include <stdint.h> int main(void) { const size_t x = 150; int a[x]; for (size_t i = 0;i < x; ++i) a[i] = i; printf("SIZE_MAX = %lu\n", SIZE_MAX); size_t size = sizeof(a); printf("size = %zu\n", size); }
Output
SIZE_MAX = 18446744073709551615 size = 600
In the above program, variable x of size_t datatype is declared. An array is also declared with the size x. size_t is a datatype of unsigned integral variable x. It is calculating the size of variable a in bytes.
printf("SIZE_MAX = %lu\n", SIZE_MAX); size_t size = sizeof(a);
- Related Questions & Answers
- Array.LastIndexOf(T[], T) Method in C#
- What are primitive data type in C++?
- Need of long data type in C
- Data type of character constants in C and C++
- Abstract Data Type in Data Structures
- What is the size of int, long type in C++ standard?
- How to use sizeof() operator to find the size of a data type or a variable in C#
- Data Type Ranges and their macros in C++
- What is data type of FILE in C?
- What is enumerated data type in C language?
- C++ set for user define data type
- C++ set for user defined data type?
- Number Data Type in Python
- String Data Type in Python
- List Data Type in Python
Advertisements