So I'm trying to write a program that will read a program that will be reading characters/strings in regular text and will output the information in hexadecimal format. An example of such is this "UNAME" = "55 4E 41 4D 45 28 31 29" in hexadecimal format. I just don't know where to start, any ideas?

Characters are 8 bit integers. Use the appropriate printf format strings. To output the hex value of a character you would use %.02x

anyway you can give me a sample code of that?

try this:-

char arr[]={"UNAME"};
for(int i=0;arr[i]!=NULL;i++)
{
printf("%x\t",arr[i]); //this is what you want
}

hope this may help you , however i am not much familiar with c programing .

To me "UNAME" converts to hex as "55 4E 41 4D 45". How you do arrive at "55 4E 41 4D 45 28 31 29", probably remains a mystery to all of us.

With reference to ur query,
int main()
{
char ch='a';
char*ptr=&ch;
clrscr();
printf("Converting character to hexadecimal format");
printf("%p",ptr);
getch();
return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.