Register to reply

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

by physicsposter
Tags: character, format, fortran, hexadecimal
Share this thread:
Mar30-12, 07:34 PM
P: 1
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?
Phys.Org News Partner Science news on
Law changed to allow 'unlocking' cellphones
Microsoft sues Samsung alleging contract breach
Best evidence yet for coronal heating theory detected by NASA sounding rocket
Apr1-12, 08:15 AM
P: 873
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.

Register to reply

Related Discussions
Fortran 77 reading from text file, printing Engineering, Comp Sci, & Technology Homework 2
Question about printing with FORTRAN Programming & Computer Science 1
Printing character arrays c++ Engineering, Comp Sci, & Technology Homework 8
Get the contents of a file, character by character Programming & Computer Science 7
Printing certain values from a DO loop in Fortran Computing & Technology 3