The VOID keyword.


The void keyword allows us to create functions that either do not require any parameters or do not return a value.

The following example shows a function that does not return a value.


	void Print_Square(int Number);

	main()
	{
	   Print_Square(10);
	   exit(0);
	}
	
	void Print_Square(int Number)
	{
	   printf("%d squared is %d\n",Number, Number*Number);
	}

The next example shows a function that does not require any parameters:


	#include 
	#include 

        int Random(void);

        main()
        {
           printf("A random number is %d\n", Random());
           exit(0);
        }

        int Random(void)
        {
	   srand((unsigned int)time((time_t *)NULL));
	   return( rand());
        }


Example:

void example

See also:

Functions Void pointers


Top Master Index Keywords Functions


Martin Leslie

0b5aaf7caf4324927'>treecommitdiff

diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-21 10:54:01 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-21 10:54:01 -0700
commitecd06f28836f9d10c92a4740b5aaf7caf4324927 (patch)
tree8ceb01018cb6701836bc127ca2a8ebe1c9b3ee57
parente59f30b417499414a1f9afaaad3a42937060832f (diff)
parente9c9346e20c1b18a3ec30defd5ff7134bcc0da6d (diff)
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A set of fixes that missed the merge window, mostly due to me being away around that time. Nothing major here, a mix of nvme cleanups and fixes, and one fix for the badblocks handling" * 'for-linus' of git://git.kernel.dk/linux-block: nvmet: use symbolic constants for CNS values nvme: use symbolic constants for CNS values nvme.h: add an enum for cns values nvme.h: don't use uuid_be nvme.h: resync with nvme-cli nvme: Add tertiary number to NVME_VS nvme : Add sysfs entry for NVMe CMBs when appropriate nvme: don't schedule multiple resets nvme: Delete created IO queues on reset nvme: Stop probing a removed device badblocks: fix overlapping check for clearing
Diffstat