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:

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

Example 2:

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

Example 3:

main()
 {
  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

    Reply

Leave a Reply