Thread: Difference between *.h and *.m files?

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    6

    Difference between *.h and *.m files?

    Why are all C objects/modules divided into 2 files, one with the .m suffix and the other with the .h suffix?

    As far as I can tell the *.h file contains all the declarations of both variables and functions, whilst the *.m file contains all the actual code for the functions. Is this right?

    What is the purpose of having 2 seperate files? Why can't it all be within one file?

  2. #2
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92
    *.m suffix? i havent seen many C files with that suffix, only the *.c suffix

    The only file i know of that uses the *.m suffix is a Matlab file. Make sure you arent looking at a matlab file, instead of a C file.

    The *.h suffix is used to include headers of definitions of function/data structures in the *.c files

    If everything was in one file, large programs would be unreadable and unmaintainable, breaking this up into managable pieces is common practice.

    Hope this clears any confusion up.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM