I'm learning C, and we have been recently been taught functions. User defined functions strike me as fascinating, and so I decided to write a simple program to try out how a function works. Here's my code:
#include"stdio.h"
int main()
{
func();
}
func()
{
printf("This program uses a function.");
}
I pressed "compile" and I got a compliler error. The exact message it gave me is:
fpermissive]
func()
^
Return code is not 0
The diagnostics do not imply a mistake in the code that I wrote, so I'm unable to find out where I made a mistake. Can someone help me fix this program, and also successfully learn how to use user defined functions?
Edit:
I had forgotten to mention the return type of the function. I did that now, and here's my modified code:
#include"stdio.h"
int main()
{
func();
return 0;
}
int func()
{
printf("This program uses a function.");
return 0;
}
I pressed compile again, and got a different error message. This one says:
was not declared in this scope
func();
^
Return code is not 0
Can someone help me?