CompuServe Messages

C subroutines?

    31-Jul-94 23:08:20
Sb: #42046-C subroutines?
Fm: Jeff Pratt 76057,3645
To: Peter Greci 76104,2110
Peter, PMFJI… your example is almost valid — what's missing is that you need to tell the compiler what kind of value your function returns, even if that is "void" ( == no value returned at all…) … also, you'll need to indicate what the compiler should be expecting as calling parameters, again, void if there are none. Some examples: void say_help( void ) { printf("Help!\n"); } Note, this would be called from inside another routine by … say_help(); … int itest( double r1, double r1 ) { if (r1<r2) return 1; else if (r2<r1) return -1; else return 0; } to call that one, … double a, b; int j; … j = itest(a,b); … etc, etc. There are lots of considerations wrt variable scope and so forth that would be covered in an introductory C book — I'd heartily recomend that you get one. The local library should have a ton of them if you don't want to spend buck$, but I use mine ALL the time (got K&R second edition, which has ansi stuff in it — there are many others that people might recomend if you wish). Also, there used to be a 4-diskette c manual available to download… I forget at the moment who by, but it was quite complete…. Good coding…. (AutoPilot'ed from) JcP