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

Ask a Question

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.