Thread: Novice question.. please help.

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    8

    Novice question.. please help.

    Im still new into C programming, and I have a quick question:

    How do you make a kind of subprogram within a program? No, not really a program but more like sequence of commands so I woudn't have to repeatedly declare it again and again?

    If my question is too confusing to understand (sorry 'bout that ), what Im talking about is C's version of Pascal's procedure.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    It's called a function in C.
    Code:
    #include <stdio.h>
    
    void foo(void) //a function!
    {
       printf("Hello");
    }
    
    int main(void)
    {
       foo();
       return 0;
    }
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. A novice programming question...
    By curious in forum C Programming
    Replies: 8
    Last Post: 11-12-2008, 06:09 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Rtfm
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 03-13-2003, 05:19 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM