How I can write a .h headerfile for this program

Discussion in 'C Programming' started by Dyana, Jan 6, 2016.

  1. Dyana

    Dyana

    Joined:
    Jan 6, 2016
    Messages:
    1
    Likes Received:
    0
    This is the complete program including description.

    #include <stdio.h>
    void dchar(char c)
    {printf ("%d\n",(int)c);}

    dchar the function is simple and press the numeric value of the passed to the function sign off.
    What do you think can go wrong in such a simple function, especially when there type security is provided.
    You can check this by compiling this short source file separately. Then enter the following source and compile it into position.

    #include <stdio.h>
    #include "myheader.h"

    extern void dchar (unsigned char);
    void main()
    {dchar(128);}

    Everything seems to be normal until you try to run the linked program. Instead of weathered deed value 128
    The value -128 is displayed. There has been an incomparable view type conversion so that the numerical value is wrong was interpreted. The process of mangling function did not even have a chance to prevent this.
    To resolve this problem by using well-written header files. Write the external declaration in a .h header files and use #include To add the header file in the program. Naturally, even now that there are errors do occur, but the probability of this method is dramatically reduced.

    ifndef __MYHEADER_H
    define __MYHEADER_H
    ifdef __cplusplus
    extern"C"{
    endif
    void dchar(unsigned char);
    void char*(char c);
    ifdef __cplusplus
    }
    endif
    endif

    I would really appreciate if you can help me. I get headaches from this program.
    PLEASE WRITE DE HEADERFILE FOR ME.

    Dyana
     
    Dyana, Jan 6, 2016
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. alicecuee@gmail.com
    Replies:
    3
    Views:
    742
    Alan Krueger
    Oct 10, 2005
  2. Saurabh Saxena

    can we write program without loops

    Saurabh Saxena, Feb 5, 2004, in forum: C Programming
    Replies:
    22
    Views:
    1,036
    Peter Pichler
    Feb 22, 2004
  3. could ildg
    Replies:
    0
    Views:
    730
    could ildg
    Jul 1, 2005
  4. Vusi
    Replies:
    5
    Views:
    711
    John Machin
    Jul 4, 2006
  5. Puneet
    Replies:
    16
    Views:
    1,433
    Daniel Vallstrom
    Mar 20, 2005
  6. freehomesp@yahoo.com.cn
    Replies:
    1
    Views:
    699
    Walter Roberson
    Aug 12, 2005
  7. sigi
    Replies:
    4
    Views:
    763
  8. sahm
    Replies:
    4
    Views:
    970
    stledger@lanl.gov
    Oct 15, 2012
Loading...