#include
typedef unsigned char *byte_pointer;
void show_bytewise(byte_pointer start, int len){
int i;
for(i = 0; i < len; i++)
{
printf("%.2x ",start[i]);
}
printf("\n");
}
void show_int(int n){
show_bytewise((byte_pointer)&n, sizeof(int));
}
void show_float(float dec){
show_bytewise((byte_pointer)&dec, sizeof(float));
}
void show_pointer(void *p){
show_bytewise((byte_pointer)&p, sizeof(void *));
}
/* Drover program to test above functions */
int main()
{
int i = 1;
float f = 1.0;
void *p = &i;
show_int(i);
show_float(f);
show_pointer(p);
return 0;
}
typedef unsigned char *byte_pointer;
void show_bytewise(byte_pointer start, int len){
int i;
for(i = 0; i < len; i++)
{
printf("%.2x ",start[i]);
}
printf("\n");
}
void show_int(int n){
show_bytewise((byte_pointer)&n, sizeof(int));
}
void show_float(float dec){
show_bytewise((byte_pointer)&dec, sizeof(float));
}
void show_pointer(void *p){
show_bytewise((byte_pointer)&p, sizeof(void *));
}
/* Drover program to test above functions */
int main()
{
int i = 1;
float f = 1.0;
void *p = &i;
show_int(i);
show_float(f);
show_pointer(p);
return 0;
}
Comments
Post a Comment