Adjusting to C++ from JAVA

Cromewell

Administrator
Staff member
There are two problems in the code above.
1. You need to Declare the function first before main().
Code:
void samplefunc();
void main(){


}

void samplefunc(){

printf("Function Definition ");
}
You can also use an inline function. Which has slightly different syntax.
And the second one is you do not pass Arrays as arguments like that.
It's called prototyping. Basically what you are doing is telling the compiler how to ensure the function is being called correctly. If you don't provide a prototype one is automatically created as returning an int and taking unknown parameters. That can create problems :)
 
Top