Part 2 : C programming FAQs
C Basics-Level 1 - Syntax
What are the basic data types
What are storage class specifiers
What are modifiers
What are Qualifiers
Explain different categories of operators in C
Explain order of evaluation of operators in C
Explain rules of defining an identifier in C
Explain rules of defining functions in C
Explain rules of writing “for” loops in C
Explain rules of writing “while” loops and “do {} while” loops in C
Explain rules of writing “switch” cases in C
Explain rules of writing “if” conditions in C
Explain rules of writing “if else” conditions in C
Explain rules of defining structures in C
Explain rules of defining unions in C
Explain rules of defining Macro functions in C
Explain rules of defining inline functions in C
Explain rules of defining a static function in C
Explain rules of defining a reentrant function in C
Explain rules of defining an integer array
Explain rules of defining a float array
Explain rules of defining a character array
Explain rules of defining a double array
Explain rules of defining structure arrays
Explain rules of defining union arrays
Explain rules of defining enums
Explain rules of defiing array of strings
Explain rules of defining an integer pointer
Explain rules of defining a float pointer
Explain rules of defining a character pointer
Explain rules of defining a double pointer
Explain rules of defining a function pointer
Write a function which takes function pointers as arguements
Write a function which returns function pointer
EXplain rules of defining array of function pointers
Explain rules of defining function pointers inside a structure
Explain rules of defiing array of integer pointers
Explain rules of defiing array of float pointers
Explain rules of defiing array of double pointers
Explain rules of defiing array of character pointers
Explain rules of defiing array of structure pointers
Explain rules of defiing array of union pointers
Explain rules of pointer arithmetic
Explain rules of using a compile time macros
Explain rules of using sizeof() operator on different types
Explain rules of structure padding
Explain rules of structure packing
Explain rules of bit fields in structures
Explain rules of zero length arrays in structures
Explain rules of using all format specifiers
C Basics-Level 2 - Differences
Difference between one’s complement and two’s compiement and application
Difference between Little endian and Big endian
Difference between OR and XOR
Difference between OR and XNOR
Difference between OR and AND
Difference between & and &&
Difference between | and ||
Difference between sizeof(int) in 32 bit and 64 bit machines
Difference between structure and union
Difference between structure padding and structure packing
Difference between macros and inline functions
Difference between normal functions and inine functions
Difference between normal functionsand static functions
Difference between “int” and “unsigned int”
Difference between “double” and “long long double”
Difference between pre-increment and post-increment in case of simple integers
Difference between pre-increment and post-increment in case of integer pointers
Difference between C and C++
Differnce between local variables and global variables
Difference between local static variable and global static variables
Difference between initialised global variables and not intialised global variables
Difference between “auto” variables and “register” variables
Difference between call by value and call by reference
Difference between while and do while
Difference between strncat and strlcat
Difference between strncpy and strlcpy
Difference between strcat and strncat
Difference between strcpy and strncpy
Difference between strcmp and memcmp
Difference between strcpy and memcpy
Difference between malloc and calloc
Difference between malloc and realloc
Difference between fopen, open
Difference between ~ and !
Difference between RAM and ROM
Difference between declaration and defintion
Difference between function prototype and function definition
Difference between printf and fprintf
Difference between float and double
Difference between variable and constant
Difference between gets and fgets
Difference between far pointers and near pointers
Difference between arrays and pointers
Difference between array of integer pointers and array of array of integers
Difference between two dimensional arrays and double pointers
Difference between modifiers and qualifiers
Difference between storage class specifiers and format specifiers
Difference between < and << operator
Difference between > and >> operator
Difference between Postfix and Prefix operations
Difference between string and array of characters
C Basics-Level 3 - Compilation stages
Explain stages of compilation involved when program is compiled
Explain memory layout of a running process
Explain memory layout of a compiled program
Differnce between Segments and sections
Differnce between code segment and data segment
Difference between BSS and initialised data segment
Difference betwen Unix and Linux
DIffernce between syntac analyser and semantic analyser
What are the responsibilities of a pre-processor
What are the responsibilities of an assembler
What are the responsibilities of a linker/loader
What are the contents of an object file
What are the contents of an ELF a.out file
C Basics-Level 4 - Searching - Arrays
Implement Linear searching algorithm
Implement binary searching algorithm
Implement my_strstr similar to strstr
Search and replace letter ‘a’ in a string with letter ‘k’
Search and replace letter ‘a’ in a string with letter ‘k’ in a file containing a plain text
C Basics-Level 5 - Sorting - Arrays
Implement bubble sort algorithm to sort an array in increasing way
Implement bubble sort algorithm to sort an array in decreasing way
Implement selection sort algorithm to sort an array in increasing way
Implement selection sort algorithm to sort an array in decreasing way
Implement insertion sort algorithm to sort an array in increasing way
Implement insertion sort algorithm to sort an array in decreasing way
Implement merge sort algorithm to sort an array in increasing way
Implement merge sort algorithm to sort an array in decreasing way
Implement quick sort algorithm to sort an array in increasing way
Implement quick sort algorithm to sort an array in decreasing way
Implement heap sort algorithm to sort an array in increasing way
Implement heap sort algorithm to sort an array in decreasing way
Implement counting sort algorithm to sort an array in increasing way
Implement counting sort algorithm to sort an array in decreasing way
Implement Radix sort algorithm to sort an array in increasing way
Implement Radix sort algorithm to sort an array in decreasing way
Implement Bucket sort algorithm to sort an array in increasing way
Implement Bucket sort algorithm to sort an array in decreasing way
Implement Shell sort algorithm to sort an array in increasing way
Implement Shell sort algorithm to sort an array in decreasing way
Sort an array of employees based on their name
Sort an array of employees based on their age
Sort an array of employees based on their salary
C Basics-Level-6 - integer Programs
Progam to find if a number is odd or even
Progam to find if a number is prime or not
Program to find the Nth fibonacci number
Program to print the fibonacci series
Program to find the factorial of a number
Program to reverse an integer. Input : 12345, Output : 54321
Program to find the power of a number; Input : Base, power Output : (Base)^Power
Program to print all prime numbers till 1000
Program to print all perfect square numbers till 1000. 1, 4, 9, 16, 25 etc.,
Program to check if a number is perfect cube or not
Program to swap two numbers stored in two different variables
Program to find sum of all numbers in an array of integers
Program to find product of all numbers in an array of integers
Program to create an union of two integer arrays
Program to create an intersection of two integer arrays
Program to remove duplicate integers in an array of integers
Program to add only even numbers in an array of integers
Program to add only odd numbers in an array of integers
Program to delete all negative numbers in an array of integers
Program to count number of integers which are palnidrome numbers in an array of integers
Program to count number of perfect cubes in an array of integers
Program to find the square root of a number
Program to find all the divisors of a given number
Program to print the tables of a given number from 1 to 10
Program to perform matrix addition
Program to perform matric multiplication
Program to reverse the contents of an integer array
Program to find the smallest element and it’s position in an array
Program to find the larget element and it’s position in an array
Program to convert to “centimeters” to “inches”
Program to convert seconds to microseconds
Program to swap two numbers without using temporary variables
Program to find the sum of all negative numbers in an array
Program to find LCM and HCF
Program to add all digits in a given integer
C Basics-Level-7 - Bitwise programs
Program to set a bit at a particular position in an integer
Program to clear a bit at a particulat position in an integer
Program to count how many bits are set in an integer
Program to count how many bits are not set in an integer
Program to check if a system is little endian or big endian
Program to swap byte3, byte 2 with byte 1, byte 0 in a 32 bit integer
Program to convert all 1s to 0s and all 0s to 1s in an integer
How negative integer numbers are represented in an integer
How negative integer numbers are represented in a float
Program to find a if a number is odd or even using bitwise operators
Program to swap two numbers without using temporary variables using bitwise operators
Program to multiply a number by 2 using bitwise operator
Program to divide a number by 2 using bitwise operator
Program to set all bits between positions M and N
Program to clear all bits between positions M and N
Program to swap bits from M,N with P,Q in an integer
C Basics-Level-8 - memory allocation programs
Program to allocate a single block of integer using malloc
Program to allocate a single block of float using malloc
Program to allocate a single block of double using malloc
Program to allocate a single block of char using malloc
Program to allocate a multiple blocks of integer using malloc
Program to allocate a multiple blocks of float using malloc
Program to allocate a multiple blocks of double using malloc
Program to allocate a multiple blocks of char using malloc
Program to allocate memory to a double integer pointer, store and access data using single and double indirection
Program to allocate memory to triple integer pointer, store and access data using single, double & triple indirection
Program to allocate memory to array of integer pointers, store and access data using indirection
Program to allocate memory to a structure pointer, store and access data using single indirection
Program to allocate memory to an array of structure pointers, store and access data using single indirection
Program to allocate memory to a double structure pointer, store and access data using indirection
C Basics-Level-9 - C library APIs
- Program to learn use of string.h APIs
strlen - calculate the length of a string
strcat - concatenate two strings
strncat - concatenate two strings
strlcat - size-bounded string concatenation
strcmp - compare two strings
strncmp - compare part of two strings
strchr - string scanning operation
strrchr - string scanning operation
strchrnul - string scanning operation
strstr - find a substring
strcasestr - find a substring
strcasecmp - case-insensitive string comparisons
strpbrk - scan a string for a byte
strsep - extract token from string
strspn - get length of a substring
strtok - split string into tokens
strtok_r - split string into tokens
strcpy - copy a string and return a pointer to the end of the result
strncpy - copy fixed length string, returning a pointer to the array end
strlcpy - size-bounded string copying
stpcpy - opy a string and return a pointer to the end of the result
strcoll - string comparison using collating information
strcspn - get the length of a complementary substring
strdup - duplicate a specific number of bytes from a string
strndup - duplicate a specific number of bytes from a string
strfry - randomize a string
strxfrm - string transformation
- Program to learn use of memory allocation APIs
malloc - a memory allocator
calloc - a memory allocator
realloc - a memory reallocator
reallocarray - a memory allocator
free - free dynamic memory
- Program to learn use of C library file operation APIs
fopen - open a stream
fdopen - associate a stream with a file descriptor
freopen - open a stream
fclose - close a stream
fmemopen - open a memory buffer stream
fflush - flush a stream
fcloseall - close all open streams
fseek - reposition a stream
ftell - return a file offset in a stream
rewind - reset the file position indicator in a stream
fgetpos - get current file position information
fsetpos - set current file position
fprintf - print formatted output
fscanf - convert formatted input
- Program to learn formatted output conversion
printf - print formatted output
fprintf - print formatted output
dprintf - print formatted output
sprintf - print formatted output
snprintf - print formatted output
vprintf - format the output of a stdarg argument list
vfprintf - format output of a stdarg argument list
vdprintf - format output of a stdarg argument list
vsprintf - format output of a stdarg argument list
vsnprintf - format output of a stdarg argument list
- Program to learn file read, write APIs
fgetc - get a byte from a stream
fgets - get a string from a stream
fputc - put a byte on a stream
fputs - put a string on a stream
getc - get a byte from a stream
getchar - get a byte from a stdin stream
ungetc - push byte back into input stream
putc - put a byte on a stream
putchar - put a byte on a stdout stream
puts - put a string on standard output
- Program to learn use of pthread_xxxx apis
pthread_create - thread creation
pthread_attr_init - initialize the thread attributes object
pthread_attr_setstacksize - set the stacksize attribute
pthread_attr_destroy - destroy the thread attributes object
pthread_join - wait for thread termination
pthread_detach - detach a thread
pthread_equal - compare thread IDs
- Program to learn apis from ctypes.h - character classification functions
isalnum - test for an alphanumeric character
isalpha - test for an alphabetic character
isascii - test for a 7-bit US-ASCII character
isblank - test for a blank character
iscntrl - test for a control character
isdigit - test for a decimal digit
isgraph - test for a visible character
islower - test for a lowercase letter
isprint - test for a printable character
ispunct - test for a punctuation character
isspace - test for a white-space character
isupper - test for an uppercase letter
isxdigit - test for a hexadecimal digit
isalnum_l - test for an alphanumeric character
isalpha_l - test for an alphabetic character
isblank_l - test for a blank character
iscntrl_l - test for a control character
isdigit_l - test for a decimal digit
isgraph_l - test for a visible character
islower_l - test for a lowercase letter
isprint_l - test for a printable character
ispunct_l - test for a punctuation character
isspace_l - test for a white-space character
isupper_l - test for an uppercase letter
isxdigit_l - test for a hexadecimal digit
- Program to learn apis from time.h
asctime - convert date and time to a string
time - get time
clock - report CPU time used
ctime - convert a time value to a date and time string
difftime - compute the difference between two calendar time values
gmtime - convert a time value to a broken-down UTC time
localtime - convert a time value to a broken-down local time
mktime - convert broken-down time into time since the Epoch
strftime - convert date and time to a string
strptime - date and time conversion
- Program to find offset of a structure member
offsetof - offset of a structure member
Note
An exercise : Complete this exercise !
Test an API by passing inputs as defined in Five modules
C Basics-Level-10 - String programs
- Implement custom definitions of below APIs, using loops (for or while)
strlen - calculate the length of a string
strcat - concatenate two strings
strncat - concatenate two strings
strlcat - size-bounded string concatenation
strcmp - compare two strings
strncmp - compare part of two strings
strchr - string scanning operation
strrchr - string scanning operation
strchrnul - string scanning operation
strstr - find a substring
strcasestr - find a substring
strcasecmp - case-insensitive string comparisons
strpbrk - scan a string for a byte
strsep - extract token from string
strspn - get length of a substring
strtok - split string into tokens
strtok_r - split string into tokens
strcpy - copy a string and return a pointer to the end of the result
strncpy - copy fixed length string, returning a pointer to the array end
strlcpy - size-bounded string copying
stpcpy - opy a string and return a pointer to the end of the result
strcoll - string comparison using collating information
strcspn - get the length of a complementary substring
strdup - duplicate a specific number of bytes from a string
strndup - duplicate a specific number of bytes from a string
strfry - randomize a string
strxfrm - string transformation
Program to search letter ‘a’ and replace it with letter ‘k’ in a string
Program to search letter ‘a’ and replace it with letter ‘k’ in an array of strings
Program to reverse a string using for or while loop
Program to reverse all strings in an array of strings
Program to convert all charcaters to capital letters in a string
Program to convert all charcaters to capital letters in all strings in an array of strings
Program to convert all charcaters to small letters in a string
Program to convert all charcaters to small letters in all strings in an array of strings
Program to replace occurance of word “paper” with “pen” in a string
Program to replace occurance of word “paper” with “pen” in all strings in an array of strings
Program to search letter ‘a’ and delete it in a string
Program to search letter ‘a’ and delete it in an array of strings
Program to replace occurance of word “paper” and delete it in a string
Program to replace occurance of word “paper” and delete in all strings in an array of strings
Program to print A-Z and a-z
Program to count number of new lines in a string or array of strings
Program to check if a string is a palindrome
Program to check if a string is a proper IPv4 address or not
Program to check if a string is a proper MAC address or not
Program to check if two strings are anagram of each other
Program to count number of words in a string where each word is separated by space
Program to remove all characters which are not alphabets in a string
Program to sort the letters in a string as per alphabetical order
Program to sort the strings in an array of strings similar to a dictionary
Program to sort all characters in all strings in an array of strings
Program to extract the digits from a string and store them in integer variables
Program to extract information from an excel sheet and store it in a proper data structure in RAM
Program to remove any leading spaces in a string or array of strings
Program to remove any trailing spaces in a string or array of strings
Program to remove leading spaces, trailing spaces and white spaces in a string or array of strings
Program to find out smallest word in an english statement
Program to find out longest word in an english statement
C Basics-Level-11- Data structure programs
Program to implement Single linked list with functions insert_at_front, insert_at_rear, insert_at_position, delete_at_front, delete_at_rear, delete_at_position
Program to implement Double linked list with functions insert_at_front, insert_at_rear, insert_at_position, delete_at_front, delete_at_rear, delete_at_position
Program to implement Binary search tree with functions insert_left, insert_right, delete_left, delete_right, search
Program to implement stacks using arrays
Program to implement stacks using Single linked lists
Program to implement Queues using Single linked lists
Program to implement stacks using Double linked lists
Program to implement Queues using Double linked lists
Program to reverse a single linked list using iteration
Program to print the left view of binary tree
Program to print the right view of binary tree
Program to create a mirror copy of binary tree
Program to implement a disctionary search of strings using hastable of single linked lists
Program to implement Min-Heap
Program to implement Max-Heap
Program to implement AVL trees
Program to implement threaded binary trees
Program to implement B+ trees
Program to implement red black trees
Program to implement double ended queues
Program to implement circular queues
Program to implement circular linked lists
Program to implement a custom malloc and free operation
C Basics-Level-12- Recursion programs
- Implement custom definitions of below APIs, using recursion
strlen - calculate the length of a string
strcat - concatenate two strings
strncat - concatenate two strings
strlcat - size-bounded string concatenation
strcmp - compare two strings
strncmp - compare part of two strings
strchr - string scanning operation
strrchr - string scanning operation
strchrnul - string scanning operation
strstr - find a substring
strcasestr - find a substring
strcasecmp - case-insensitive string comparisons
strpbrk - scan a string for a byte
strsep - extract token from string
strspn - get length of a substring
strtok - split string into tokens
strtok_r - split string into tokens
strcpy - copy a string and return a pointer to the end of the result
strncpy - copy fixed length string, returning a pointer to the array end
strlcpy - size-bounded string copying
stpcpy - opy a string and return a pointer to the end of the result
strcoll - string comparison using collating information
strcspn - get the length of a complementary substring
strdup - duplicate a specific number of bytes from a string
strndup - duplicate a specific number of bytes from a string
strfry - randomize a string
strxfrm - string transformation
Program to implement tower of hanoi using recursion
Program to reverse a string using recursion
Program to reverse a linked list using recursion
Program to print fibonacci series usinf recursion
Program to find sum of all numbers in an integer array using recursion
Program to implement insert_at_rear and delete_at_rear using recursion in single linked lists
Program to print the contens of an integer array using recursion
Program to print A-Z or a-z using recursion
Program to print sum of digits of an integer using recursion
Program to find GCD of two numbers using recursion
Program to find factorial of a number using recursion
Convert all above programs having loops to recursion
C Basics-Level-13- File operation programs
Program to create an empty file
Program to write 1 to 100 into a file
Program to write a string to a file
Program to write an array of strings to a file
Program to count number of characters in a file
Program to count number of words in a file
Program to count number of new lines in a file
Program to count number of occurances of character ‘a’ in a file
Program to create a file which is a copy of another file
Program to print list of file names present in the current directory
Program to delete a file in the current directory whose name matches the input arguement
Programt to search and replace letter ‘a’ with letter ‘k’ in a file
Program to seach and replace word “paper” with the word “pen” in a file
Program to count how many ip address strings are present in a file
Program to count how many mac address strings are present in a file
Program to delete occurances of “paper” in a file
Program to search and replace all occurances of words “paper”, “book” with “pen” and “pencil” respectively
Program to count number of anagrams in a file
Program to count number of palindromes in a string
Program to delete all the contents of a file
Program to delete all new lines in a file
Program to number of lines, number of characters and number of words in a file
Program to split an input file and create two files exactly into two halves
Program to split an input file into multiple files based on number of lines input by the user
Program to split an input file into multiple files based on output size input by the user
C Basics-Level-14- Applications of Data structures
Store the list of club membership records in a file named ""Club_Membership_2020.txt"" and use the file as input for the below 30 questions:
Abbrevations:
SLL: Singly linked list
DLL: Doubly linked list
CSLL: Circular singly linked list
CDLL: Circular doubly linked list
$ cat Club_Membership_2020.txt
ID Name Gender Occupation Age
1001 Jennifer Crawford Female Engineer 32
1002 Skylar Sean Female Author 25
1003 Angelina John Female Doctor 45
1004 Karen Tatum Female Doctor 34
1005 Tanya Brown Female Engineer 34
1006 Frank Bryce Male Doctor 50
1007 Jason Frank Male Doctor 49
1008 Jimmy White Male Author 33
1009 Lenny Bruce Male Engineer 37
1010 Lara Kilarney Female Doctor 49
1011 Martha Stalwart Female Politician 41
1012 Ron Wesley Male Driver 35
1013 Minnie Drover Female Actor 35
1014 Tom Fullerton Male Actor 34
1015 Carl Jackson Male Manager 60
SLL: Store the list of records in a singly linked list. Print all entries in the linked list.
SLL: Store the list of records in a singly linked list after sorting the records in alphabetic order by member names. Print all entries in the linked list.
SLL: Store the list of records in 2 singly linked lists according to gender. Print all entries in each linked list.
SLL: Store the list of records in mutiple SLL according to age buckets (21-30, 31-40, 41-50, 51-60). Print all entries in each linked list.
SLL: Store the list of records in a singly linked list. Print all entries in the linked list. Delete all records which fall in the age bucket of 21-30 and print the SLL once again.
SLL: Store the list of records in a singly linked list. Print all entries in the linked list. Increase the age of all members by 1 and print the SLL once again.
SLL: Store the list of records in a singly linked list. Print all entries in the linked list. While displaying the SLL, print an additional text “[Mark for title upgrade]” for all members whose age is greater than 45.
SLL: Store the list of records in a singly linked list. Delete every alternate entry in the SLL.
CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list.
CSLL: Store the list of records in a circular singly linked list after sorting the records in alphabetic order by member names. Print all entries in the CSLL but starting from the alphabet J
CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list. Delete all records which match the occupation “Engineer” and print the CSLL once again.
CSLL: Store the list of records in a circular singly linked list. Print all entries in the linked list. Modify the ID of all records by adding the value 100 to it and print the CSLL once again.
CSLL: Store the list of records in a circular singly linked list. Print only the members in the CSLL who are above the age of 40 and match the occupation “Doctor”.
CSLL: Store the list of records in a CSLL. Delete every alternate entry in the CSLL
DLL: Store the list of records in a doubly linked list. Print all entries in the DLL
DLL: Store the list of records in a doubly linked list after sorting the records in alphabetic order by member surnames. Print all entries in the DLL.
DLL: Store the list of records in 2 singly linked lists according to gender. Print all entries in each DLL starting from the tail of the DLL.
DLL: Store the list of records in mutiple DLLs according to age buckets (21-30, 31-40, 41-50, 51-60). Print the DLL. Delete the entries in the age bucket 41-50 and print the DLL once again
DLL: Store the list of records in mutiple DLLs according to age buckets (21-30, 31-40, 41-50, 51-60). The records in the age bucket must be storted acording to increasing age. Print all entries in each DLL in reverse age order for each bucket.
DLL: Store the list of records in a doubly linked list. Sort all entries according to occupation. Print only one entry for each occupation.
DLL: Store the list of records in a doubly linked list. Sort all entries alphabetically according to occupation. Delete entries such that only one entry is present for each occupation in the DLL.
DLL: Store the list of records in a doubly linked list. Delete every alternate entry in the DLL.
DLL: Store the list of records in a doubly linked list. Sort all entries alphabetically according to occupation and print the DLL(Order should be: Actor list <-> Author list <-> Doctor <-> Engineer <-> Manager <-> Politician). Swap the order for the occupation entries “Doctor” and “Engineer” (Order should be Actor <-> Author <-> Engineer <-> Doctor <-> Manager <-> Politician)
CDLL: Store the list of records in a circular doubly linked list. Print all entries in the CDLL
CDLL: Store the list of records in a circular doubly linked list after sorting the records in alphabetic order by member names. Print all entries in the CDLL, starting from the alphabet M but in reverse alphabetic order.
CDLL: Store the list of records in a circular doubly linked list. Print only the members in the CDLL who are above the age of 40.
CDLL: Store the list of records in a CDLL. Print only the members of the CDLL whose first or last name start with the letter J
CDLL: Store the list of records in a CDLL. Delete all entries whose occupation matches Actor and print the CDLL.
CDLL: Store the list of records in a CDLL. Entries must be sorted according to occupation. Print the CDLL.
CDLL: Store the list of records in a CDLL. Delete every alternate entry in the CDLL
C Basics-Level-15 - Structures
Experiment all examples in below categories |
Structure syntax |
Structure Single Pointers |
Structure Double Pointers |
Structure Triple Pointers |
Structure padding |
Structure packing |
Structure bitfields |
Zero length arrays in structures |
Difference between structures and unions |
Function pointers inside structures |
Self referential pointers in structures |
Read ahead structure declaration |
Structures declaration with typedef |
Anonymous structures |
Structures inside a union |
Unions inside a structure |
Structures with in a structure |
Passing structure as function arguments |
Returning structure as function return types |
C Basics-Level-16 - Macros
Experiment all examples in below categories |
Object-like Macros |
Function-like Macros |
Macro Arguments |
Stringizing |
Concatenation |
Variadic Macros |
Predefined Macros |
Undefining and Redefining Macros |
Directives Within Macro Arguments |
Macro Pitfalls |
C Basics-Level-17 - Function Pointers
Write sample programs to underatnd below function pointer declarations |
|
Declaration |
Description |
typedef int (*fptr)(int, int); fptr fp; |
fp is a function pointer which can hold the address of a function which takes two integers as a parameter and returns an integer |
typedef int fptr(int, int); fptr *fp; |
fp is a function pointer which can hold the address of a function which takes two integers as a parameter and returns an integer |
typedef int (*fptr)(int, int); fptr fp[10]; |
fp is an array of function pointers where each function pointer can hold the address of a function which takes two integers as a parameter and returns an integer |
typedef int fptr(int, int); fptr *fp[10]; |
fp is an array of function pointers where each function pointer can hold the address of a function which takes two integers as a parameter and returns an integer |
typdef int (*fptr)(int, int); fptr fun(fptr) |
fun is a function which takes a function pointer as an arguement and returns a function pointer |
typdef int fptr(int, int); fptr *fun(fptr *) |
fun is a function which takes a function pointer as an arguement and returns a function pointer |