I have these 3 code files in C. My problem is that even though the function name is typed wrongly the program is still compiling.I am using GNUC. Here are the 3 files. The Error is Highlighted. main.c Code: #include <stdio.h> #include "functions.h" int main() { int j, num; float radius[50], height[50]; scanf("%d", &num); for( j = 0; j < num; j++) { scanf("%f%f", &radius[j], &height[j]); } for ( j = 0; j < num; j++ ) { if ( testContainer(radius[j], height[j]) ) printf("Container radius: %f, height: %f\n", radius[j], height[j]); } return 0; } function.c Code: #include <stdio.h> #include "functions.h" float calculateVolume(float r, float h) { return 3.142 * r * r * h; } int testContainer(float r, float h) { if ( 500 <= calculateVolume(r, h) ) return 1; return 0; } functions.h Code: #ifndef FUNCTION_H #define FUNCTION_H float [B][COLOR=DarkRed]claculate[/COLOR][/B]Volume(float r, float h); int testContainer(float r, float h); #endif My questions are ? 1)What is the Error ? 2) Is it Machine Dependent ? 3)Is it version dependent (e.g turboc,gnuc,etc.) ? Thanking you.
I dont see any error. You have claculateVolume as function prototype and calculateVolume as function body but as you are not calling either. Nope Nope
Sure Sir. I am not understanding even though the function prototype is not matching,why no error is reported ? Is the "function.h" really making any significant contribution to the program except for function definition ?
There isnt any error because you are trying to make a call to them. Say you have 10 such functions defined but if you dont call them there is not any error that can be reported. If you call either of them you will likely to get an error. If you call the one in .c file you will get the error its not defined If you call the .h one you will get function body not defined error .h files are meant for providing an interface to the cpp file which have the actual function which is what is tried in the above problem.