Skip to content
Sign upLog in
← Back to Community

Functions not working on repl.it

Profile icon
ZachT78

I am writing a C program using functions, and Repl.it will not allow me to create them (Function definition is not allowed here), however they will work on other compilers.

Is there a certain format used for creating functions with repl.it?

https://repl.it/@ZachT78/PCW027

Voters
Profile icon
TerezaVitria
Profile icon
RoshanGG
Profile icon
ZachT78
Comments
hotnewtop
Profile icon
mwilki7

I don't understand the syntax of defining functions inside functions.
You should define functions in the main scope of the file, i.e. outside of any other function.

int main() { int f1() { // no! } }
int main() { } int f1() { // yes }