1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Credit: Bishal Kumar Dubey -- License: CC-BY-SA-4.0
// Copied verbatim from https://www.geeksforgeeks.org/_generic-keyword-c/
// C program to illustrate macro function.
#include <stdio.h>
#define geeks(T) _Generic( (T), char: 1, int: 2, long: 3, default: 0)
int main(void)
{
// char returns ASCII value which is int type.
printf("%d\n", geeks('A'));
// Here A is a string.
printf("%d",geeks("A"));
return 0;
}
|
© Copyright 2019 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.