What is the use of sizeof() operator in C?

The sizeof operator returns the size in bytes of its operand. Operand may be a variable or data type.

Here are few examples,

Example 1:

  char c;
  printf("%d,%d\n", sizeof c, sizeof(int)); /* returns 1, 4*/

Example 2:

	   int a;
	   int b;
	printf ("% d \ n", sizeof (s)); /* returns 8*/

Start exploring endless computing possibilities with your own Raspberry Pi computer and accessories. Perfect for beginners and students.

Example 3:

  short array [] = {1, 2, 3, 4, 5};
  short la = sizeof (array) / * returns 10 * /

One Response to “What is the use of sizeof() operator in C?”

  1. this site is worst
    give the answers your site not me
    what is this
    please not repeated this silly sites ok


Leave a Reply to rambha

Click here to cancel reply.