void pointer as Function Argument in C programming - void pointer in C



 void pointer as function argument in c programming

Learn C - C tutorial - void pointer as function argument in c programming - C examples - C programs

void pointer as function argument in C programming

  • The void pointer is also known as generic pointer, this pointer can be pointed at objects of any type.
  • A void pointer is declared like a normal pointer, using the void keyword as the pointer's type:
    void *ptr; // ptr is a void pointer.

Sample Code

#include <stdio.h>
void printString(void *ptr);
int main()
{
    char *str="hi there";
    printString(str);
    return 0;
}
void printString(void *ptr)
{
    printf("str: %s\n",ptr);
}

Output

str: hi there


View More Quick Examples


Related Searches to void Pointer as Function Argument in C programming - void Pointer in C