Thread: header file

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    11

    header file

    how can i create my own header file like provided in Turbo c.

    I tried to understand the header file stdio.h i cant understand a bit.
    can anyone explain.

    How can i make my own datatype, which can more value than a long integer. Please give a detailed program.
    Last edited by denny; 05-28-2002 at 07:23 AM.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    Code:
    /* myheader.h */
    
    #include <stdio.h>
    
    typedef long int LONGINT;
    
    /* END OF HEADER */
    here is your header file, must be in the same directory as your program below...

    Code:
    /* MY PROG.C */
    
    #include "myheader.h"
    
    int main (void)
    {
    
       LONGINT  long_value;
    
       printf("Enter a  whole number :");
       scanf("%ld" &long_value);
    
       printf("\nYou entered %ld", long_value");
       return 0;
    }
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How can i make my own datatype, which can more value than a long integer.
    You can do this relatively easily using one of two ways: First you can create your own datatype by linking together several structs which each hold a certain length of the value. As you can imagine, the code to create and manipulate this is probably a little involved than you want. Second, you can use a double and remove the decimal when printing. This is the easiest way and it's difficult to overflow a double unless you're doing calculations that a language without value limits would be better suited for. You can also use an implementation dependent data type that is larger. Most compilers have one of these, such as MSVC++'s __int64.

    >Please give a detailed program.
    Heheh
    Code:
    #include <stdio.h>
    
    typedef double really_long_int;
    
    int main ( void )
    {
      really_long_int rli = 1234567898765432.0;
      printf ( "%.0f\n", rli );
      return 0;
    }
    I'll let you write the code for the first option since it's an excellent exercise in both programming and mathematics. Or you can cheat and go to snippets.org.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. Replies: 30
    Last Post: 06-19-2006, 12:35 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM