How to compile any C program as a beginner: What compiler options are recommended for beginners learning C?
Following this advise and compiling with gcc gives 2 problems:
<source>:2:6: error: return type of 'main' is not 'int' [-Wmain]
2 | void main()
| ^~~~
<source>: In function 'main':
<source>:11:21: error: format '%[^
' expects argument of type 'char *', but argument 2 has type 'char (*)[28]' [-Werror=format=]
11 | scanf("%27[^\n]%*c",&in);
| ~~~~~^~ ~~~
| | |
| char * char (*)[28]
The first reported error is because void main() is an implementation-defined form of main() which isn't suitable for gcc unless you explicitly compile for embedded systems or the like. Switch to int main (void).
The second reported error says that the conversion %c expected a parameter of type char*. You gave it a parameter of type char (*)[28]. Huh, what is that? Well, it is a pointer to an array of 28 char. Not the same thing and not what you want, but what you get if you do &in instead of in.
Luckily, viewing multiple lines of the gcc output gives you the exact location of the bug, after which you will find the bug in seconds:
11 | scanf("%27[^\n]%*c",&in);
| ~~~~~^~ ~~~
| | |
| expect BUG HERE FIX ME
Now if you follow the above guidelines, you should be able fix the next trivial bug that the compiler has already found.