How do I make sub routines, and how do i clear the screen? thanks
This is a discussion on sub routines and clearing the screen within the C++ Programming forums, part of the General Programming Boards category; How do I make sub routines, and how do i clear the screen? thanks...
How do I make sub routines, and how do i clear the screen? thanks
state your compiler for clearing screen...sub routines are simple...
first off: they're not suroutines, they're functions. they're really simple to do:
that code calls the function myfunc() to display "Tada!" on the screen.Code:#include <stdio.h> void /*no return value*/ myfunc(void/*no input*/) { printf("Tada!\n"); } int main(void) { myfunc(); return 0; }
passing a value to a function is simple, too:
and that should display Tada! 5 times.where I wrote int numtimes in the function declaration, it tells the compiler that it needs to be passed an integer value to wrok properly.Code:#include <stdio.h> void myfunc(int numtimes) { int x; for(x=0;x<numtimes;x++) printf("Tada!\n"); } int main(void) { myfunc(5); return 0; }
Gays can't love like real people
entropysink.com -- because arses weren't designed for running websites.
Oh yeah, I'm in th C++ board...just change all the printf's to cout's
Gays can't love like real people
entropysink.com -- because arses weren't designed for running websites.