Fortran: printing the Printing the Hex contents of a character variable

  • #1

Main Question or Discussion Point

Given a character variable

character*10 name

write (6,111) name

111 format (?)

what do I put in the format statement to print the hexadecimal contents of name?
 

Answers and Replies

  • #2
1,065
53
Hhhmmm...I have never had such need. I don't think there is such a shortcut in Fortran as there is in C; so, I am afraid you are going to have to write your own little function to do so.

First, you will have to convert the character to decimal; you can use ichar(letter) for that. But then, you need your own little recursive function to produce hex. Here is a simple explanation of how to go about it for any decimal.
 

Related Threads on Fortran: printing the Printing the Hex contents of a character variable

  • Last Post
Replies
2
Views
1K
Replies
1
Views
2K
Replies
7
Views
7K
Replies
5
Views
219
Replies
7
Views
10K
Replies
7
Views
125K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
11
Views
1K
Replies
3
Views
2K
  • Last Post
Replies
3
Views
2K
Top