sub routines and clearing the screen

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...

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    sub routines and clearing the screen

    How do I make sub routines, and how do i clear the screen? thanks

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    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:

    Code:
    #include <stdio.h>
    void /*no return value*/ myfunc(void/*no input*/)
    {
        printf("Tada!\n");
    }
    
    int main(void)
    {
        myfunc();
        return 0;
    }
    that code calls the function myfunc() to display "Tada!" on the screen.

    passing a value to a function is simple, too:

    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;
    }
    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.

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Oh yeah, I'm in th C++ board...just change all the printf's to cout's

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. screen flicker more info
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-08-2001, 10:54 PM
  2. screen flicker
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-06-2001, 10:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21