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
#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