I am trying to do a program where the function is pointed by a pointer. It goes as follows:-
This is the first program which uses “void” return type.
#include<stdio.h>
#include<conio.h>
void CharPrint(char *ptr);
main()
{
char *str="Hello World";
void (*ptr1)(char *ptr);
ptr1=CharPrint;
if((*ptr1)(str))
printf("Done");
return 0;
}
void CharPrint(char *ptr)
{
printf("%s\n",ptr);
}
It throws many errors. They are:-

The second program is as follows:-
#include<stdio.h>
#include<conio.h>
int CharPrint(char *ptr);
main()
{
char *str="Hello World";
int (*ptr1)(char *ptr);
ptr1=CharPrint;
if((*ptr1)(str))
printf("Done");
return 0;
}
int CharPrint(char *ptr)
{
printf("%s\n",ptr);
return 0;
}
This program runs without any hiccup.
The output is:-

My problem is that in the first output, why is it showing ” Not an allowed type in function main ” on line 9. The other lines are also arising doubts but this line is bugging me the most. Any help?
What is the
iftesting if the return value isvoid? Just change the last two lines to: