I'm trying to call a function in main for the different programs (Q2-3 and Q4) but I'm getting an error during compiling. in my main I have prog1 (); [it says "previous implicit declaration of prog1 was here"] then there is a function of the same name at the very end void prog1() { [it says "conflicting types for prog1"] and yes it just says it on a line where the only thing is {
the [] are just what I typed here not what is in my code. If you need more parts of my code let me know. My program is written in C not C++
Because you didn't give a prototype for prog1()
.
If it has for example the following signature
char *prog1(void);
and you don't give a prototype but call it from main()
, then you define it later with the mentioned signature, the implicitly declared prototype which is int prog1()
conflicts with the definition.
Just add a prototype before main()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.