first of all: i don't know what %h does or if it even exists, but %x should normally give you hex output.
You must also understand that C doesn't really have a string type, you have to use arrays to store your stuff in.
printf("%s", string); will print out your entire string, but other operands won't do that.
%c, %d, %x will only work for one value.
So how do we solve this problem?
We can make a string and then go through all the values and print them
CODE
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i;
char string[] = "aaaaaaaaa";
for(i = 0; i < (strlen(string)); i++) {
printf("%x ", string[i]);
}
return 0;
}
However, instead of using fget() to make an array, and then going through all our values one by one, we can also just change them at the input line:
CODE
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int ch;
while( (ch = getchar() ) != '\n') {
printf("%x ", ch);
}
return 0;
}
this program will take a character at a time from the standard input and then print its hexadecimal value, until a newline is reached.
I hope this answers your question,
if it doesn't or you don't understand some things,
let me know,
gilbert