Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1077823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:38:00+00:00 2026-05-16T21:38:00+00:00

Why do some people write methods in header file ? And what’s the difference

  • 0

Why do some people write methods in header file ?

And what’s the difference between writing a method in a procedure file and a header file?

Here’s the code :

Work.h

#include <time.h>

void DoWork(int n)
{
    clock_t t = clock() + n * CLOCKS_PER_SEC / 1000;
    while(clock() < t);
}

Program.c

#include <stdio.h>
#include "work.h"
int main(void)
{
     printf("Starting work\n");
     DoWork(100);
     printf("Work has finished\n");
}

Is there any difference between writing a method in a procedure file and header file or are they same?

Edit 1 : The only difference I know is if I write DoWork() in procedure file, then I have to compile the procedure file and then pass the object code, while compiling the main program.

Thanks.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:38:00+00:00Added an answer on May 16, 2026 at 9:38 pm

    The preprocessor will – among other things – recursively replace all #include directives by the code of these headers included. (Basically, it’s a dumb text replacement machine.) The result, a source file with all included headers recursively copied into it, is called a translation unit. Effectively, this is what your compiler sees (although modern compilers often mesh together different stages of the translation process in order to be faster).
    You can have multiple translation units contribute to a single resulting program. (In fact, with anything above 50 lines of code, that’s pretty much the standard.)

    When you are defining functions in headers (as opposed to only declaring them), and the headers with these definitions are then included in multiple source files that are to be linked to some executable, then the linker will find multiple definitions of the same functions, and give up emitting a nasty error message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking at some ruby code and noticed that some people treat methods
I see some people write: //wordList is List<string> wordList.ForEach(delegate(string word){ Console.WriteLine(word);}); instead of: foreach(string
why do some people make a new reference in method to a field variable?
I have been writing some code that creates a generic blog. Its features are
For writing unit tests, I know it's very popular to write test methods that
I'm writing a plugin for Cinch (the IRC bot), and trying to write some
Some people at the office feel uncomfortable having to disable macro security for outlook
Some people set default src to img element in the following way: <img src=foo.jpg
Some people load the google places api with a client parameter, example : <script
Some people have mentioned RockScroll and MetaScroll in This Question , but those only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.